embeddedartistry / libc

libc targeted for embedded systems usage. Reduced set of functionality (due to embedded nature). Chosen for portability and quick bringup.
MIT License
504 stars 67 forks source link

Add sanitizer step to ci #149

Closed noahp closed 3 years ago

noahp commented 3 years ago

Summary

Add a step to ci that runs AddressSanitize, UndefinedBehaviorSanitizer, and LeakSanitizer.

Tweak the make shim to forward any sanitizers specified into meson args.

Testing

At the moment unable to run the tests on my machine; they hang in the libc_tests stage with:

1/3 printf_tests      OK             0.37s
2/3 libc_tests        TIMEOUT        30.01s
3/3 stackprotect_test EXPECTEDFAIL   0.22s
phillipjohnston commented 3 years ago

Thanks @noahp!

Do you know which particular sanitizer(s) were hanging for you? I've seen one of them fail completely (Address, I think) due to libc tests that check handling of NULL input cases, which are handled differently by the sanitizer library.

noahp commented 3 years ago

Thanks @noahp!

Do you know which particular sanitizer(s) were hanging for you? I've seen one of them fail completely (Address, I think) due to libc tests that check handling of NULL input cases, which are handled differently by the sanitizer library.

:'( actually I can't successfully run the test on the previous commit, using a ubuntu 20.04 host if that's important. Let me try in a ubuntu 18.04 dockerfile, just a second.

phillipjohnston commented 3 years ago

Hm, I'll look into that. I recently fixed a problem that occurred on Ubuntu, I'll make sure that actually landed :).

phillipjohnston commented 3 years ago

@noahp,

Can you see if changing the disable-builtins to true resolves the hang for you with Ubuntu? (Note that you'll need to reconfigure the project or use meson configure for it to take effect)

option('disable-builtins', type: 'boolean', value: false,
    description: 'Tell the compiler not to generate builtin functions.',
    yield: true)
noahp commented 3 years ago

Yup, that worked! with builtins enabled, here's where it hangs:

> gdb buildresults/test/libc_test
...
>>> bt
#0  0x0000555555560dcb in calloc ()
#1  0x00007ffff7bd0231 in _cmocka_run_group_tests () at buildresults/test/../subprojects/cmocka-1.1.5/src/libcmocka_native.so.0
#2  0x00005555555569c2 in isalnum_tests ()
#3  0x0000555555556640 in ctype_tests ()
#4  0x0000555555556500 in main ()

Spins forever there.

noahp commented 3 years ago

Apologies, this patch has gotten a little stale! going to close and reopen once I get a chance to finish working through the sanitizer false positives.