Description of problem: libmongoclient.so in libmongodb-2.4.6-1.el6.x86_64 is built with scons --use-system-all, which results in linking tcmalloc from libmongoclient.so. This is 1) undesirable because libraries should leave the choice of allocator up to the user of the library and 2) causes an application that uses libmongoclient.so to crash if it is prelinked, apparently due to a static initialization order issue. The appropriate flag to use when building the library is --use-system-boost rather than --use-system-all. Note that the linking of tcmalloc if --use-system-all is specified is in itself a bug in the mongodb build, tracked by https://jira.mongodb.org/browse/SERVER-12400; however --use-system-boost is the appropriate flag to use when building the library and will also resolve this problem in the EPEL RPM. Note that the above applies to the libmongoclient.so library *only*. The mongod server process should be built using --use-system-all and should link tcmalloc. Version-Release number of selected component (if applicable): libmongodb-2.4.6-1.el6.x86_64 How reproducible: deterministic Steps to Reproduce: 1. create simple hello world test.cpp 2. compile with: g++ -o test test.cpp -lmongoclient 3. run with: ./test Actual results: aborts with *** glibc detected *** /root/prelink-test/test: free(): invalid pointer: 0x0000000000e31200 *** Expected results: prints "hello world" Additional info:
What's the proper fix, then? Patch mongodb 2.4.6 so that --use-system-all actually works? Because the current build is done with a single scons command for both the library and the server, so just changing the parameter would affect both.
Would it be easier to change your build to use two separate scons commands, one for the library and one for the server? The downside of a patch is that it may create more work to maintain as you move to future versions of MongoDB. I think either fix would work, it just depends on what you feel more comfortable with.
It sounds feasible as starting with version 2.6.0, the libmongoclient library is completely separated from mongodb (and will be provided as separate package - now I'm starting to work on it). Currently I'm running out if time though to patch this old EPEL version to use two separate scons commands. Any volunteer?
We already have to maintain a Sconstruct patch, because on the 2.4 version of mongodb there were several libraries that were not working with the local versions. (Note: Those were fixed in 2.6, thank you) I was going to take this on, but I can't seem to reproduce the error. So I wouldn't know if I fixed it. [user@64RHEL6 test]$ cat test.cpp // 'Hello World!' program #include <iostream> int main() { std::cout << "Hello World!" << std::endl; return 0; } [user@64RHEL6 test]$ g++ -o test test.cpp [user@64RHEL6 test]$ ./test Hello World! [user@64RHEL6 test]$ g++ -o test1 test.cpp -lmongoclient [user@64RHEL6 test]$ ./test1 Hello World! [user@64RHEL6 test]$ echo "Just did prelink" Just did prelink [user@64RHEL6 test]$ g++ -o test2 test.cpp -lmongoclient [user@64RHEL6 test]$ ./test2 Hello World! ## Rebooted machine incase of cache ## [user@64RHEL6 test]$ g++ -o test3 test.cpp -lmongoclient [user@64RHEL6 test]$ ./test3 Hello World! Can you verify that you only have one libmongoclient.so installed?
Here's a more detailed repro script, including prelink commands to force the prelink; does this help? Also included some commands to show which version of libmongoclient.so is being linked, just to verify. + cat test.cpp #include <iostream> int main() { std::cout << "Hello World" << std::endl; return 0; } + g++ -o test test.cpp -lmongoclient + sudo /usr/sbin/prelink -u --all + sudo /usr/sbin/prelink test + ./test *** glibc detected *** ./test: free(): invalid pointer: 0x0000000002a99200 *** ======= Backtrace: ========= /lib64/libc.so.6[0x3001476166] /usr/lib64/libmongoclient.so(_ZN5mongo23InputStreamSecureRandomD0Ev+0x25)[0x30004d91a5] /usr/lib64/libmongoclient.so(_ZN5mongo3OID16genMachineAndPidEv+0x4c)[0x300046303c] /usr/lib64/libmongoclient.so[0x3000463142] /usr/lib64/libmongoclient.so[0x3000517566] ... + ls -l /usr/lib64/libmongoclient.so -rwxr-xr-x. 1 root root 1404104 May 15 16:13 /usr/lib64/libmongoclient.so + md5sum /usr/lib64/libmongoclient.so 65ed5698505f5178bbbb4d6af9068cdc /usr/lib64/libmongoclient.so + rpm -qf /usr/lib64/libmongoclient.so libmongodb-2.4.6-1.el6.x86_64
This should be now fixed in el6. If this issue is still actual feel free to reopen.
mongodb-2.4.12-3.el6 has been submitted as an update for Fedora EPEL 6. https://admin.fedoraproject.org/updates/mongodb-2.4.12-3.el6
Package mongodb-2.4.12-3.el6: * should fix your issue, * was pushed to the Fedora EPEL 6 testing repository, * should be available at your local mirror within two days. Update it with: # su -c 'yum update --enablerepo=epel-testing mongodb-2.4.12-3.el6' as soon as you are able to. Please go to the following url: https://admin.fedoraproject.org/updates/FEDORA-EPEL-2015-0744/mongodb-2.4.12-3.el6 then log in and leave karma (feedback).
mongodb-2.4.12-3.el6 has been pushed to the Fedora EPEL 6 stable repository. If problems still persist, please make note of it in this bug report.