Danny
Danny

Reputation: 2683

Ok to use newer (or both) libstdc++ on 32-bit Centos 6?

Our legacy product ships on 32-bit Centos 6.6, which has gcc 4.4.7 built in. However, the large app sometimes crashes from glibc corruption. Recompiling with gcc 4.8 and AddressSanitizer finds "global-buffer-overflow" and then crashes. However, compiling with gcc 4.9 seems to fix things: no glibc corruption and no AddressSanitizer errors.

The problem is the the app now requires libstdc++.so.6.0.20 and no longer works with the stock Centos 6 libstdc++.so.6.0.13 (GLIBCXX_blahblah not found, etc)

So what's the best approach?

  1. Replace the stock /usr/lib/libstdc++ with the new one?
  2. Package the new libstdc++.so.6.0.20 with our app (in a private directory) and modify /etc/ld.so.conf.d to load the private/new library before the system copies.

In #1, the file is owned by another package, so might again be overwritten by some future update. Also, would existing programs break if the /usr/lib version was updated? I read a lot on ABI compatibility but it is a complex subject.

Thanks for your feedback.

Upvotes: 1

Views: 274

Answers (1)

Alexandre Fenyo
Alexandre Fenyo

Reputation: 4819

Your problem is to get minor interaction with other software.

So, avoid replacing the stock version of the library.

Moreover, there would also be possibly interractions with other software using /etc/ld.so.conf.

So, the best way to avoid any interaction with other sotfware is to:

  • either statically link your libstdc++ 6.0.20 to your legacy product or app (you need the sources, or at least the independent objects files, to do that, so it may not be possible);
  • or install libstdc++.so.6.0.20 in a specific directory, like /usr/local/my-own-version-for-my-app/lib, and instead of publishing this directory with ld.so.conf, use :
    • a LD_LIBRARY_PATH env var set to /usr/local/my-own-version-for-my-app/lib:$LD_LIBRARY_PATH, just before launching your app:
    • or set the LD_PRELOAD env var this way: LD_PRELOAD=/usr/local/my-own-version-for-my-app/lib/libstdc++.so.6.0.20, just before launching your app.

This means writting:

% export LD_LIBRARY_PATH=/usr/local/my-own-version-for-my-app/lib:$LD_LIBRARY_PATH
% ./launch_my_app

or:

% export LD_PRELOAD=/usr/local/my-own-version-for-my-app/lib/libstdc++.so.6.0.20
% ./launch_my_app

Upvotes: 1

Related Questions