[gmpi] Re: Linux C++ question

  • From: Jeff McClintock <jeffmcc@xxxxxxxxxx>
  • To: gmpi@xxxxxxxxxxxxx
  • Date: Thu, 24 Feb 2005 15:14:21 +1300

> I provided a destructor for GMPI_Factory.  If I call GMPI_DllClose()
> before exiting from main(), then I get a segfault.

Google groups..
" I'm running into a problem on Linux while dynamically loading and
 unloading DSOs. The problem is, if I build with --fuse-cxa-atexit I
 get a segmentation fault on exit from main()"

`-fuse-cxa-atexit'
     Register destructors for objects with static storage duration with
     the `__cxa_atexit' function rather than the `atexit' function.
     This option is required for fully standards-compliant handling of
     static destructors, but will only work if your C library supports
     `__cxa_atexit'.

http://groups.google.co.nz/groups?hl=en&lr=&threadm=5e0d1266.0408310613.3345e97a%40posting.google.com&rnum=3&prev=/groups%3Fq%3Ddlclose%2Bcrash%2Bmain%26hl%3Den%26lr%3D%26selm%3D5e0d1266.0408310613.3345e97a%2540posting.google.com%26rnum%3D3

Would be nice to have standard-complient code.

Hope that helps,
jeff

Tim Hockin wrote:
On Wed, Feb 23, 2005 at 02:28:33PM -0800, Tim Hockin wrote:

On Thu, Feb 24, 2005 at 11:26:49AM +1300, Jeff McClintock wrote:

It blows up after the final return of main.  What I suspect is that the
GMPI_Factory destructor is being called, but the DLL is already unloaded.

Does putting a printf("Factory destructor.. int the destructor provide more info (may have to provide a destructor, I didn't)?


I provided a destructor for GMPI_Factory.  If I call GMPI_DllClose()
before exiting from main(), then I get a segfault.  If I don't call
DllClose, the GMPI_Factory destructor DOES run.

If I don't provide a destructor, it fails to load the DLL:
undefined symbol: _._12GMPI_Factory

So I made the Factory instance use new and delete and actually be
refcounted.

Problem gone.  I'll post all the code as soon as I have assured myself
that both the C and C++ are correct.  Like I said - I'm learning some C++
as I go :)  Google is a good teacher.

----------------------------------------------------------------------
Generalized Music Plugin Interface (GMPI) public discussion list
Participation in this list is contingent upon your abiding by the
following rules:  Please stay on topic.  You are responsible for your own
words.  Please respect your fellow subscribers.  Please do not
redistribute anyone else's words without their permission.

Archive: //www.freelists.org/archives/gmpi
Email gmpi-request@xxxxxxxxxxxxx w/ subject "unsubscribe" to unsubscribe




----------------------------------------------------------------------
Generalized Music Plugin Interface (GMPI) public discussion list
Participation in this list is contingent upon your abiding by the
following rules:  Please stay on topic.  You are responsible for your own
words.  Please respect your fellow subscribers.  Please do not
redistribute anyone else's words without their permission.

Archive: //www.freelists.org/archives/gmpi
Email gmpi-request@xxxxxxxxxxxxx w/ subject "unsubscribe" to unsubscribe

Other related posts: