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

David Abrahams david.abrahams at rcn.com
Sun May 19 18:59:32 CEST 2002


----- Original Message -----
From: "Michael Owens" <owensmk at earthlink.net>


> 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.

Hmm, did you supply a definition for B::connect anywhere?

> 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.

Please post the code you used to expose A and B to Python, and a snippet of
Python code which causes the crash.

Thanks,
Dave







More information about the Cplusplus-sig mailing list