I'm witnessing bizarre behaviour with my dynamic C++ libraries on Solaris.
Thought I'd ask here, because y'all managed to solve the first half of my
problem };*)
Originally I was using "ld" to link my libraries, which worked fine except
that it failed to catch exceptions thrown by main-app functions called from
the libraries. I was advised to use g++ to link my libraries, since that's
what I was using to link the main application.
Success! All of the exceptions were now caught correctly.
BUT - Failure!
Previously, when the libraries were linked using ld, I could quite happily
overwrite the .so files with a new library; I coded the main app to detect
that, dlclose() the current version of the library and dlopen() the new
version, and carry on.
This is now broken. If I persuade the main app to reload the library
(without changing it), it works fine. If I change the .so file on disk and
then try the reload process, my application crashes (sometimes SEGV,
sometimes Illegal Instruction) in dlclose()
Any ideas what's going on? It's almost as if dlclose() is referring back to
the .so on disk to find out how to shut the library down, and tripping over
the fact that the code offsets are now different. But I can't understand why
that wasn't happening before with ld.
I haven't changed any other compiler or linker options, just literally
swapped "ld" for "g++". I'm using RTLD_NOW in dlopen (i.e. I'm not using the
GLOBAL or NODELETE parameters)
Any thoughts appreciated,
Paul
{company disclaimer snipped -mod}
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
0
|
|
|
|
Reply
|
Paul
|
8/13/2004 4:46:17 PM |
|
Paul Harman wrote:
> I'm witnessing bizarre behaviour with my dynamic C++ libraries on Solaris.
> Thought I'd ask here, because y'all managed to solve the first half of my
> problem };*)
<snip>
> Previously, when the libraries were linked using ld, I could quite happily
> overwrite the .so files with a new library; I coded the main app to detect
> that, dlclose() the current version of the library and dlopen() the new
> version, and carry on.
>
> This is now broken. If I persuade the main app to reload the library
> (without changing it), it works fine. If I change the .so file on disk and
> then try the reload process, my application crashes (sometimes SEGV,
> sometimes Illegal Instruction) in dlclose()
>
> Any ideas what's going on?
There might be a bug in the destructor for a static object, that you
are coincidentally provoking.
> It's almost as if dlclose() is referring back to
> the .so on disk to find out how to shut the library down, and tripping over
> the fact that the code offsets are now different. But I can't understand why
> that wasn't happening before with ld.
<snip>
Unix marks executable files, including shared libraries, as "busy" or
read-only so long as they are loaded into a process. Presumably when
you rebuild the shared library it is unlinked rather than overwritten,
meaning that the old version remains on disk until it is unloaded.
If the finalisation code for the shared library needs to be paged in
when it is closed, it will be paged in from the old version and not
the new version.
However, if there is something wrong with the "busy" mechanism then
your explanation makes perfect sense.
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
0
|
|
|
|
Reply
|
Ben
|
8/14/2004 4:33:10 AM
|
|
|
1 Replies
259 Views
(page loaded in 0.039 seconds)
Similiar Articles: Solaris 10 issue? Failed dlopen() leaves library loaded. - comp ...... cropped up since we upgraded a system to Solaris 10. ... the app was compiled with, and, if not, dlclose ... PKGADD Error - comp.unix.solaris... pkgadd: ERROR ... Static Linking Problem - comp.unix.programmer... return 0;} int dlclose ... compiles OK, but when I link it to the program I receive several errors ... The problem is that Solaris sets its defgw to its own link-local ... Re: Solaris (8) How to reset pseudo terminal defaults - comp.unix ...... to see if there's anything strange in /dev/pts (strange links ... The software is an old Solaris binary of `rtn' a ... pseudoterminal is > setup: >1081716708554381 ERROR ... lpr .errors - comp.unix.solarisgetting following message on Sun Solaris lpstat[15935]: [ID 773474 lpr.error ... is it a real file, or a symbolic link to ... Strange error with type-spec - comp.lang.fortran ... segmentation fault when shared object using STL is statically ...... solution to this. I am using GCC 3.3.2, on Solaris... ... I use -G which works fine but -shared gives errors ... so, gives segmentation fault for ... unix.solaris When I link the ... soft partitions showing as "Errored" - comp.unix.solaris ...My soft partitions are showing as Errored in metastat. I can't find any documentation on what this means or how to fix it. Weird thing one of them i... how to re-read a partition table on Solaris? - comp.unix.solaris ...... the disk as having only 17840 cylinders), this results in strange error message being displayed by Solaris ... you are using software RAID, this(information via that link ... Error upgrading firmware on Sun Blade 100 - comp.unix.solaris ...... use...@gmail.com> wrote: > > how do I make a link ... T2000 Firmware upgrade - comp.unix.solaris Error upgrading ... Summary: Sun Blade 100 - strange behavior after ... dynamic libraries, importing symbols - comp.unix.programmer ...... possible also on other platforms (Linux, Solaris, AIX)? ... printFoo); if (ret != 0) { dlclose(handle ... Walkthrough: Creating and Using a Dynamic Link Library. When does a program receive SIGABRT - comp.unix.solaris... NULL) { cmnError (LOGGED_ERROR, "dt ... comp.unix.programmer Greetings, I am very strange for that! I work on Solaris ... receive SIGABRT - comp.unix.solaris Any link compiling wpa_supplicant - howto fix dlerror, dlsym, dlopen ...Visit the following links: Site Howto | Site FAQ | ... supplicant - howto fix dlerror, dlsym, dlopen, dlclose errors ... Slackware / Debian / *Ubuntu / Opensuse / Solaris ... Dynamically Loaded (DL) Libraries... loaded at program link time or start-up; instead, there is an API for opening a library, looking up symbols, handling errors, and ... the same as that used in Solaris ... 7/13/2012 2:31:14 AM
|