Add csafe and cppsafe executables with sanitizers support #1878
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
We are using a modified version of the C executable in our introductory programming course. In contrast to other programming languages, C has a lot of behavior that is undefined but does not throw an immediate error. For example, it does not check if memory accesses are valid, as it is considered the responsibility of the user. Consider the following C code:
While it may be fit for purpose in a competitive programming context, it clearly contains an out of bounds access to the array, due to looping
i<=100001
instead ofi<100001
. The instructor may want to automatically detect and consider this kind of mistakes as not correct, and may want to force the user to fix the bug. Example in our Domjudge instance changing the C executable for the Csafe version, changes the veredict from correct to runtime error, and prints the line where the invalid access was produced.Additional notes:
-static
flag was removed from the script as it was incompatible with some sanitizer checks and I am not sure why it is necessary.Any suggestion or feedback is welcome. Thanks @isaaclo97 for the help testing and validating the idea.