[C++-sig] trouble with virtual methods

David Abrahams david.abrahams at rcn.com
Sun Feb 3 16:53:24 CET 2002


Looking at the Boost.Python code, it seems to me that either of these
mistakes should cause a C++ exception to be thrown. There are only two
explanations I can think of for your crash:

1. The code surrounding your use of callback<>...::call(...) isn't
exception-safe.
2. Your compiler's exception-handling implementation has a bug.

If you raise a Python exception from within your Python GetTexture method
you should see a similar crash. If you care about robustness, it would be
worth your while to track this down.

-Dave

----- Original Message -----
From: "Hugo van der Merwe" <s13361562 at bach.sun.ac.za>
To: <c++-sig at python.org>
Sent: Sunday, February 03, 2002 6:31 AM
Subject: Re: [C++-sig] trouble with virtual methods


> > Will let you know what my results are, thanks.
> > Hugo
>
> I have finally gotten round to "debugging" this issue, had enough other
> things to work on before requiring virtual methods.
>
> gdb told me the following:
>
> (gdb) add-shared-symbol-files demeter.so
> This command is not available in this configuration of GDB.
>
> So I didn't bother with that.
>
> As it turns out, the error was in the Python code:
>
> >>> import demeter
> >>> class boo(demeter.TextureFactory):
> ...   def GetTexture(a, b, c, d, e): print "gotcha:",a,b,c,d,e
> ...
> >>> tf = boo();
> here I am
> >>> demeter.func(tf)
> Aborted
>
> Notice I forgot the "self" parameter in that GetTexture - GetTexture
> only has 5 parameters, instead of the 6 it should have.
>
> Another problem with this code is that it does not call return, this
> also causes the program to bomb out.
>
> >>> class boo(demeter.TextureFactory):
> ...   def GetTexture(a, b, c, d, e):
> ...     print "gotcha:",a,b,c,d,e
> ...     return 1
>
> That solved it for me.
>
> Thanks,
> Hugo
>
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig
>





More information about the Cplusplus-sig mailing list