Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Fix sanitizer issues #788

Closed
markus2330 opened this issue Jun 13, 2016 · 11 comments · Fixed by #1644
Closed

Fix sanitizer issues #788

markus2330 opened this issue Jun 13, 2016 · 11 comments · Fixed by #1644
Assignees
Milestone

Comments

@markus2330
Copy link
Contributor

markus2330 commented Jun 13, 2016

Hello newcomer

Since 702cd0c one can easily enable undefinied behavior sanitizer.

Simply use clang as toolchain and use debug/asan (e.g. by adding -DENABLE_DEBUG=ON -DENABLE_ASAN=ON -DCMAKE_C_COMPILER=clang-3.8 -DCMAKE_CXX_COMPILER=clang++-3.8 to your cmake invocation). It might work for gcc, too.

Then try to run all tests (see tree.libelektra.org/doc/TESTING.md) and fix some issues that are reported. Do not try to fix all at once, but create a PR as early as possible.

See also:
https://build.libelektra.org/jenkins/job/elektra-clang-asan/lastFailedBuild/console
https://build.libelektra.org/jenkins/job/elektra-gcc-asan/lastFailedBuild/console

@rautesamtr
Copy link
Contributor

Should we open separate bugs per found undefined behavior or just add them here?

@markus2330
Copy link
Contributor Author

I am not sure if it is useful to list them at all. There are quite many and its easy to trigger them. But you can add them here.

@rautesamtr
Copy link
Contributor

This one in keyset.c
/src/libs/elektra/keyset.c:922:11: runtime error: unsigned integer overflow: 42 + 18446744073709551592 cannot be represented in type 'unsigned long'

the used nickel library seems to have quite some in hash.c that should probably just suppressed as it is not really part of elektra
/elektra/src/plugins/ni/nickel-1.1.0/src/hash.c:

and one in the resolver.c
/src/elektra/src/plugins/resolver/resolver.c:95:16: runtime error: member access within null pointer of type 'resolverHandles' (aka 'struct _resolverHandles')

@markus2330
Copy link
Contributor Author

markus2330 commented Nov 18, 2016

I updated the issue to use -DENABLE_ASAN=ON. ENABLE_DEBUG does not activate asan anymore.

@sanssecours
Copy link
Member

sanssecours commented Jul 20, 2017

Since the ASAN build jobs do not build all plugins, here are some other tests that currently also fail on my machine after I enable the address sanitizer:

  • testjna_maven
  • test_kdb.lua
  • test_key.lua
  • test_keyset.lua

.

@markus2330
Copy link
Contributor Author

The error messages would be interesting. If lua/java cause the problems we might have to exclude the tests (at least for the version/OS where it does not work).

I get now a segmentation fault I had not earlier (only with ASAN):

[ 13%] Generating exported_symbols.h
Segmentation fault
src/libs/elektra/CMakeFiles/elektra-core.dir/build.make:53: recipe for target 'src/libs/elektra/exported_symbols.h' failed

Unfortunately, no core dump gets generated, even though they are activated. Have to investigate it later.

@sanssecours
Copy link
Member

The error messages would be interesting.

Below are logs of the individual tests. Hope they are helpful.

It looks like the Lua tests fail cause the address sanitizer is not loaded correctly:

35: ==14551==ERROR: Interceptors are not working. This may be because AddressSanitizer is loaded too late (e.g. via dlopen). Please launch the executable with:
35: DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/8.1.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib
35: "interceptors not installed" && 0

.

@markus2330
Copy link
Contributor Author

markus2330 commented Jul 21, 2017 via email

@sanssecours
Copy link
Member

…do the tests work without ASAN?

Yes.

Disabling these tests for ASAN&&APPLE could be an option?

Do these tests work on Linux with enabled ASAN? Anyway, as long as I do not need any functionality of the Java or Lua bindings, disabling these tests if address sanitization is enabled is fine with me.

@markus2330
Copy link
Contributor Author

markus2330 commented Jul 21, 2017 via email

@sanssecours
Copy link
Member

So I would say you can disable the maven/java/jni tests with ASAN on any
system and lua only for Mac OS X?

Sounds good to me. I included commits that disable the tests in pull request #1548.

e1528532 added a commit to e1528532/libelektra that referenced this issue Jul 27, 2017
e1528532 added a commit to e1528532/libelektra that referenced this issue Oct 24, 2017
sanssecours pushed a commit to sanssecours/elektra that referenced this issue Oct 26, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants