3

Original Problem:

I currently have a program that loads two shared libraries a.so and b.so dynamically. Both libraries load libcrypto.so (OpenSSL). If the program ends, there is a double free or corrupted error. I already checked my program for errors. Indexes are in bounds, and no dynamic memory is used.

To me it seems as the libcrypto.so library is detached twice at the end of the program. Is there a way to prevent this? Preferably without having to use different instances of libssl, as storage and memory are within close limits.

Im using Ubuntu 14.04 LTS, wrote the libraries in C, and compiled them using gcc with -fpic.

Thanks for your help!

PS: Might be related : Static library loaded twice

//Edit: The same problem occurs if a.so and b.so link the libssl statically.

///Edit: The same problem occurs if a.so links statically and b.so links dynamically. (a.so is used first.) If a.so is linked dynamically and b.so statically, an error in libcrypto occurs on RSA_check_key(..).

Answer

//// Edit: I minimized my code more and found that i was additionally linking something twice statically. This caused the first problem

New Problem:

As mentioned in the second edit, the RSA_check_key fails if libcrypto was linked statically first and then dynamically. Any ideas what happened here?

Community
  • 1
  • 1
Martze
  • 921
  • 13
  • 32

1 Answers1

0

What error is returned? If not already done so, please also have a look at https://www.openssl.org/docs/crypto/RSA_check_key.html