Unit tests do segfault
Closed this issue · 5 comments
I installed orthanc-mongodb 1.0.3 in a centos 6 docker container, following the build instructions. I made only few amendments, e.g. I used devtoolset-6 because devtoolset-4 is not part of centos 6 any more.
The build succeeds, but the tests crash:
mespak@mikilin:~/src/orthanc-docker/centos$ docker run --network host -it orthanc-centos-debug-build
[root@mikilin /]# cd orthanc-mongodb-build/
[root@mikilin orthanc-mongodb-build]# ./IndexTest
[==========] Running 9 tests from 2 test cases.
[----------] Global test environment set-up.
[----------] 8 tests from MongoDBBackendTest
[ RUN ] MongoDBBackendTest.Attachments
Segmentation fault (core dumped)
I started mongodb with the docker run -d --network host mongo
command beforehand, and I can connect to it from the host.
Here is the call stack at the crash:
[root@mikilin orthanc-mongodb-build]# . /opt/rh/devtoolset-6/enable
[root@mikilin orthanc-mongodb-build]# gdb -q ./IndexTest /tmp/core.mikilin.IndexTest.1534965898
Reading symbols from ./IndexTest...done.
[New LWP 13]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib64/libthread_db.so.1".
Core was generated by `./IndexTest'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0x00000000004b3c6c in mongoc_counter_client_pools_active_add (val=1) at ../mongo-c-driver/src/mongoc/mongoc-counters.defs:48
48 COUNTER(client_pools_active, "Client Pools", "Active", "The number of active client pools.")
Missing separate debuginfos, use: debuginfo-install cyrus-sasl-lib-2.1.23-15.el6_6.2.x86_64 glibc-2.12-1.212.el6.x86_64 gtest-1.5.0-5.el6.x86_64 keyutils-libs-1.4-5.el6.x86_64 krb5-libs-1.10.3-65.el6.x86_64 libcom_err-1.41.12-24.el6.x86_64 libgcc-4.4.7-23.el6.x86_64 libselinux-2.0.94-7.el6.x86_64 libstdc++-4.4.7-23.el6.x86_64 libuuid-2.17.2-12.28.el6_9.2.x86_64 nss-softokn-freebl-3.14.3-23.3.el6_8.x86_64 openssl-1.0.1e-57.el6.x86_64 zlib-1.2.3-29.el6.x86_64
(gdb) bt
#0 0x00000000004b3c6c in mongoc_counter_client_pools_active_add
(val=1) at ../mongo-c-driver/src/mongoc/mongoc-counters.defs:48
#1 0x00000000004b3c87 in mongoc_counter_client_pools_active_inc () at ../mongo-c-driver/src/mongoc/mongoc-counters.defs:48
#2 0x00000000004b4142 in mongoc_client_pool_new (uri=0xa13ff0) at ../mongo-c-driver/src/mongoc/mongoc-client-pool.c:150
#3 0x00007f1b98806240 in mongocxx::v_noabi::pool::pool (this=0xa13a70, uri=..., options=...) at /mongo-cxx-driver/src/mongocxx/pool.cpp:43
#4 0x0000000000464aba in OrthancPlugins::MongoDBBackend::MongoDBBackend (this=0xa13a50, context=0xa13a00, connection=0xa13f50) at /orthanc-mongodb/IndexPlugin/MongoDBBackend.cpp:68
#5 0x0000000000489a7c in std::make_unique<OrthancPlugins::MongoDBBackend, _OrthancPluginContext_t*, OrthancPlugins::MongoDBConnection*>(_OrthancPluginContext_t*&&, OrthancPlugins::MongoDBConnection*&&) (
__args#0=@0x7fffcf50aa68: 0xa13a00, __args#1=@0x7fffcf50aa60: 0xa13f50) at /opt/rh/devtoolset-6/root/usr/include/c++/6.3.1/bits/unique_ptr.h:791
#6 0x0000000000488a9e in MongoDBBackendTest::SetUp (this=0xa13d40) at /orthanc-mongodb/Tests/IndexTest.cpp:81
#7 0x00007f1b982fd023 in testing::Test::Run() () from /usr/lib64/libgtest.so.0
#8 0x00007f1b982fd188 in testing::internal::TestInfoImpl::Run() () from /usr/lib64/libgtest.so.0
#9 0x00007f1b982fd245 in testing::TestCase::Run() () from /usr/lib64/libgtest.so.0
#10 0x00007f1b9830010f in testing::internal::UnitTestImpl::RunAllTests() () from /usr/lib64/libgtest.so.0
#11 0x00000000004880f3 in main (argc=1, argv=0x7fffcf50ac98) at /orthanc-mongodb/Tests/IndexTest.cpp:434
(gdb)
The StorageTest fails in the very same way.
This is the Dockerfile:
and this is the command that builds the same image:
docker build --target=build -t orthanc-centos-debug-build --build-arg ORTHANC_BUILD_TYPE=Debug .
Any idea why is this? Did I miss to set up the environment correctly?
Cheers,
Miklos
(Not sure if this is the right forum to report this.)
The crash happens in release mode as well.
It seems the problem is cxx driver. I've tried with the updated versions and it worked for me.
I'm just attaching updated Docker file.
Dockerfile.1.1.txt
The end to end test passed.
BTW: Centos 7 and Dev toolset 7 also should work fine.
Thank you very much for the updated docker file! It helped me find the problem. I think, it's neither the centos-7 nor the devtoolset-7, but not even the version of the drivers. I tried to upgrade the drivers in the meantime as well (to 1.10.3 and 3.3.1, resp.), but the test crashed in the same way.
The actual problem was the --disable-automatic-init-and-cleanup
option that I translated to -DENABLE_AUTOMATIC_INIT_AND_CLEANUP:BOOL=OFF
at the driver upgrade, but which is missing from your docker file. (The other difference is the static build but that does not affect the crash.)
I saw that @kosch has updated the build instructions to CentOS 7 and devtoolset-7 today, which is fine but he added the -DENABLE_AUTOMATIC_INIT_AND_CLEANUP:BOOL=OFF
option as well. I'm afraid that won't work, you may want to remove that. :)
Looks like this is not an issue any more.