[C++-sig] Segfaults in Pure Virtual Functions in Extension Module

Michael Owens owensmk at earthlink.net
Sun May 19 18:53:08 CEST 2002


I am writing an extension module on Linux and have run into a problem with 
receiving segmenation faults when calling classes with virtual functions. The 
function in question is reimplemented from a pure-virtual function in the 
base class.

gdb only shows that the attempt to call the function results in SIGSEV. The 
object is allocated, and I don't see any dangling pointers. I am at a loss as 
to how to even determine what is failing. I suspect it has something to do 
with the VTable, but don't know how to work around it. Non-virtual functions 
do not cause this problem.

Basically, it looks like this:

class A
{
	virtual bool connect() = 0;
};

class B : public A
{
	virtual bool connect();
};

When I instantiate B anywhere in the extention module and then call connect(), 
boom.

I was wondering if it was related to exporting the symbols of B, and tried 
building the library with -rdynamic, but that did not help.

Any suggestions would be greatly appreciated.






More information about the Cplusplus-sig mailing list