prosyslab-classroom / cs348-information-security

61 stars 10 forks source link

[Question][Hw6] Coverage.read doesn't close the input channel of coverage file? #327

Closed m-spitfire closed 1 year ago

m-spitfire commented 1 year ago

Name: Murad Bashirov

Hello. How does autograder calculates coverage in json parser? I have num of unique crashes: 5, but covered lines: 0.

m-spitfire commented 1 year ago

I think I found the reason. When I do timeout x at some point Coverage.read gives EMFILE error, which in the end I end up with too many open files. I don't get the file descriptor from Coverage.read to close the file, how can I deal with this issue?

m-spitfire commented 1 year ago

This diff solves the issue:

diff --git a/src/coverage.ml b/src/coverage.ml
index 9d17c0e..673328a 100644
--- a/src/coverage.ml
+++ b/src/coverage.ml
@@ -22,6 +22,6 @@ let read coverage_file =
         line |> List.tl |> List.hd |> String.trim |> int_of_string
       in
       (if count > 0 then add line_number coverage else coverage) |> loop ic
-    with End_of_file -> coverage
+    with End_of_file -> close_in ic; coverage
   in
   loop ic empty

but as I can't modify the src/coverage.ml file, I'm not sure what to do.

yeonhee-ryou commented 1 year ago

We accumulates the coverage information in *.gcov file. Check if the files are generated well during the execution.

m-spitfire commented 1 year ago

@yeonhee-ryou my issue title is misleading now. I read that file every time I test it, but don't close it->it results in EMFILE error, which returns early with an error.

yeonhee-ryou commented 1 year ago

I'll check your issue and make a comment tomorrow

m-spitfire commented 1 year ago

solved it via implementing my own read coverage function. will keep open for the update. Edit: update: #329