-
-
Notifications
You must be signed in to change notification settings - Fork 181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problems in pascals-triangle test #929
Comments
The memory will be freed when the process exits, but it means that we will fail memory checks using ASan, Valgrind, etc. If we want to remove the current restriction, we should require the implementation to provide a function like |
Sorry, like there's already a |
@ryanplusplus You mean there are memory checks as part of testing the solution? If yes I think it will be really helpful to see their output as part of test run or the check when submitting the solution to learn the need to explicitly freeing memory |
I think the |
For the zeros it is a toss up between those or NULL. |
That documentation is for doing exercises locally. What about the web editor? |
Running other make targets via the web UI will depend on the test runner in https://github.com/exercism/c-test-runner . |
It depends. Do we need to run things twice? Will it be slow to run? |
I think that we would not need to run things twice. Generally speaking (may need to run tests to prove it later), the execution time difference should not be large. If there is a big issue with a given submission I guess it would run into the allowed run time limits on the Docker infrastructure. Some complexity comes when processing the results of that to present it to the user. ❯ ./bin/run-tests -p -e pascals-triangle
Copying practice exercises pascals-triangle
Running tests for pascals_triangle
Compiling memcheck
test_pascals_triangle.c:174:test_no_rows:PASS
-----------------------
1 Tests 0 Failures 0 Ignored
OK
=================================================================
==9727==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 8 byte(s) in 1 object(s) allocated from:
#0 0x7fe189457a57 in __interceptor_calloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:154
#1 0x560ca110e180 in create_triangle pascals_triangle.c:17
#2 0x560ca110e773 in test_no_rows test_pascals_triangle.c:46
#3 0x560ca110df17 in UnityDefaultTestRun test-framework/unity.c:1837
#4 0x560ca110e868 in main test_pascals_triangle.c:174
#5 0x7fe1890bdd8f (/lib/x86_64-linux-gnu/libc.so.6+0x29d8f)
SUMMARY: AddressSanitizer: 8 byte(s) leaked in 1 allocation(s).
make: *** [makefile:28: memcheck] Error 1 As you can see the test itself passes (the data returned from the function under test does match the expected data). Changing this output into what is presented to the user is done by the There are already past discussions on the test-runner repo in exercism/c-test-runner#10 and exercism/c-test-runner#11. There are questions there about if this should instead go in the analyzer, if it is too complex for students with less experience, and if it is supported on the infrastructure. |
We don't have a direct Grafana or Elastic board, sorry. If you run things locally, what is the type of perf hit you're taking? |
Heres a quick test on my local machine using the run-tests.sh within this track repo. ~/repos/c[main]❯ time ./bin/run-tests -e pascals-triangle
real 0m0.341s
user 0m0.040s
sys 0m0.004s
~/repos/c[main]❯ time ./bin/run-tests -e pascals-triangle
real 0m0.051s
user 0m0.003s
sys 0m0.006s the memcheck build is slower, but we're talking milliseconds. |
Yeah, 250ms is probably fine! |
{1, 1, 2, 1, 3, 3, 1, 4, 6, 4, 1}
and an array of pointers at right positions should be the right solution.tearDown
? Leaked memory should be freed anyway after all tests finish (or am I missing something?), but having expectation about used structure intearDown
may cause a segmentation fault instead of a list of failing tests in casefree
is called on wrong pointer. I went with reserving space for all rows in onemalloc
to save on calls and reduce memory usage and had problems understanding that for me the case with 0 rows was failing and causingfree
to cause segmentation fault. It was introduced in Update tests_pascals_triangle.c: Fix memory leaks #755 and probably better to ping @bobahop{ { 0 } }
in result, shouldn't it be expecting 0 rows, or even be ok withNULL
?The text was updated successfully, but these errors were encountered: