Skip to content
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

memerr tests fail because a malloc call is replaced by a built-in #94

Closed
dtelsing opened this issue Jul 14, 2023 · 2 comments
Closed

memerr tests fail because a malloc call is replaced by a built-in #94

dtelsing opened this issue Jul 14, 2023 · 2 comments

Comments

@dtelsing
Copy link

The memerr tests rely on replacing malloc with a wrapper which fails after a certain number of calls. If the malloc call is replaced by the compiler however, this breaks some tests.

When building with gcc version 11.3.0 for i686-unknown-linux-gnu with -O2 optimizations, this lead test_memerr in tests/test_selection.c to dereference a null pointer, because select_atoms (in src/selection.c) continues further than intended and dereferences selection_dummy.atom (==NULL).

Therefore, it would be good to build the library with -fno-builtin-malloc or build the tests separately with that flag enabled.

@mittinatten
Copy link
Owner

Yes, I have also noticed that compilers/linkers have gotten pickier about this since I wrote the test 7 years ago. Thanks for your suggestions. I think I will hide these tests behind a configure flag (--enable-memerr-tests) and add some directions to the docs.

Either way, since this is not systems code, the functionality that is verified by these tests isn't that crucial either, so I have also considered simply removing these tests.

@mittinatten
Copy link
Owner

I added the flag and far as I can tell it hides all the tests, it also avoids compiling the helper code that does the replacement.

I think using the flag -fno-builtin-malloc could be beneficial, but I don't know if it's worth it to set up a complete separate build for the tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants