Crashes with shared libs - where can I learn more about shared libs and ld?
From: Carsten Fuchs (CarstenFuchs_at_T-Online.de)
Date: 05/11/05
- Previous message: w.boeke: "How to quit only a subwindow?"
- Next in thread: Paul Pluzhnikov: "Re: Crashes with shared libs - where can I learn more about shared libs and ld?"
- Reply: Paul Pluzhnikov: "Re: Crashes with shared libs - where can I learn more about shared libs and ld?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 11 May 2005 17:04:47 +0200
Dear ng,
I'm currently working on a rather big g++ program. The program compiles
and links just fine and without warnings. During run-time, it
dynamically loads shared libs with dlopen().
However, running the program frequently yields "Segmentation fault" or
"Illegal instruction" aborts. These aborts occur for example when code
within a shared lib accesses static variables of the main program (e.g.
via a pointer or reference to that static variable).
I tried to employ the gdb / ddd debuggers in order to track the cause
for the crashes down, but was not able to obtain any helpful insight.
The symptoms (occurring/disappearing of the crashes) change when for
example an .o file is linked to the main program that however is not
required for normal linking of the main program otherwise.
I've already read resources like
http://www.gnu.org/software/binutils/manual/ld-2.9.1/ld.html
http://en.tldp.org/HOWTO/Program-Library-HOWTO/index.html
Although the compile and link produces no warnings or errors, I feel
that I'm still compiling and/or linking the main program or the shared
libs in a wrong manner, but I was not able to deduce the origin of the
problems from the docs alone.
- Is compiling with -fpic strictly required for shared libs?
- Can a specific .o file (either being compiled with or without -fpic)
be linked both to a shared lib as well as to the main program, and the
resulting shared lib be dlopen()'ed into the main program?
- What are the "semantic" differences between Linux shared libs and
Windows DLLs? My program runs just fine under Windows, and I'm much more
familiar with the semantics of Windows DLLs than those of Linux shared
libs. (Grossly spoken: DLLs are "separate, individual programs" that
are reference-counted if multiple instances are loaded, whereas shared
libs...?)
Summarizing this yields my question from above:
Where and how can I learn more about shared libs and ld?
Alternatively, can somebody give me a hint about factors that can cause
shared libs to trigger aborts like "Illegal instruction"?
I'm aware that the above is only a very gross description of the
problem. I'd be happy to supply more details - if only I know which
details are relevant. (I've tried many things during the past few days,
and thus rather post an overview here first.)
Thank you very much for your help!
Best regards,
Carsten
-- Ca3D - Engine http://www.Ca3D-Engine.de Carsten Fuchs http://www.Ca3D-Engine.de/c_Carsten.php
- Previous message: w.boeke: "How to quit only a subwindow?"
- Next in thread: Paul Pluzhnikov: "Re: Crashes with shared libs - where can I learn more about shared libs and ld?"
- Reply: Paul Pluzhnikov: "Re: Crashes with shared libs - where can I learn more about shared libs and ld?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]