Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 1058434 - libmongoclient.so has dependency on tcmalloc resulting in app crash after prelink
Summary: libmongoclient.so has dependency on tcmalloc resulting in app crash after pre...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora EPEL
Classification: Fedora
Component: mongodb
Version: el6
Hardware: Unspecified
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: Marek Skalický
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-01-27 19:13 UTC by Bruce Lucas
Modified: 2015-03-08 22:47 UTC (History)
9 users (show)

Fixed In Version: mongodb-2.4.12-3.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-03-08 22:47:33 UTC


Attachments (Terms of Use)

Description Bruce Lucas 2014-01-27 19:13:24 UTC
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:

Comment 1 Matthias Saou 2014-02-04 09:56:48 UTC
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.

Comment 2 Bruce Lucas 2014-04-18 20:04:24 UTC
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.

Comment 3 jpacner 2014-05-09 09:38:52 UTC
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?

Comment 4 Troy Dawson 2014-05-09 21:49:59 UTC
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?

Comment 5 Bruce Lucas 2014-05-15 20:19:30 UTC
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

Comment 6 Marek Skalický 2015-02-11 14:16:46 UTC
This should be now fixed in el6.

If this issue is still actual feel free to reopen.

Comment 7 Fedora Update System 2015-02-11 14:43:36 UTC
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

Comment 8 Fedora Update System 2015-02-14 02:52:44 UTC
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).

Comment 9 Fedora Update System 2015-03-08 22:47:33 UTC
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.


Note You need to log in before you can comment on or make changes to this bug.