#816 php5 segfault on %extend method when making proxy classes

closed-fixed
php (58)
5
2007-05-26
2007-04-14
No

I ran swig on a file that works nicely in other languages, and swig segfaulted. I found that if I ran with -noproxy I no longer got the segfault.

I'm attaching a testcase with the swig files and copies of the necessary headers. If you run "build.sh", you should get the segfault.

Please let me know if there is anything further I can do to help.

Discussion

  • Monty Taylor

    Monty Taylor - 2007-04-14

    segfault testcase

     
  • John Lenz

    John Lenz - 2007-04-15

    Logged In: YES
    user_id=153408
    Originator: NO

    If you could, can you try and get the crash to happen on a single small example file? Try and find which class is causing the problem.

    Also, which version of SWIG are you using? The latest SVN or 1.3.31?

     
  • Monty Taylor

    Monty Taylor - 2007-04-15

    Logged In: YES
    user_id=43580
    Originator: YES

    Yes. I'll see if I can track down which class it is...

    I've actually tried with 1.3.31 and with latest SVN. No difference :(

     
  • Monty Taylor

    Monty Taylor - 2007-04-15

    Logged In: YES
    user_id=43580
    Originator: YES

    Here you go - a very small test case. Two classes. One extended method.
    File Added: testcasesmall.tgz

     
  • Monty Taylor

    Monty Taylor - 2007-04-15

    small testcase

     
  • Olly Betts

    Olly Betts - 2007-04-15

    Logged In: YES
    user_id=14972
    Originator: NO

    I've had a quick look - I think the problem is caused by the extend method, which AIUI is implemented by SWIG as a non-method in the C++ wrapper code. I simply didn't consider this case when I wrote the code to generate PHP5 wrappers, so it assumes it has a class node to play with.

    The segfault is easy to fix, but making it actually do the correct thing may be a little more involved. I'll take a look.

     
  • Olly Betts

    Olly Betts - 2007-04-15
    • assigned_to: kruland --> olly
    • summary: php5 segfault when making proxy classes --> php5 segfault on %extend method when making proxy classes
     
  • Olly Betts

    Olly Betts - 2007-04-15

    Logged In: YES
    user_id=14972
    Originator: NO

    The attached patch seems to allow swig to process this example successfully, though it's really tidying up after the problem rather than addressing it directly I think. But if you could try it on your full version and see if it allows it to work that would tell me if I'm on the right track, which would be very useful.
    File Added: php-extend-wrapper.patch

     
  • Monty Taylor

    Monty Taylor - 2007-04-15

    Logged In: YES
    user_id=43580
    Originator: YES

    I tried the patch out, and it does not segfault any longer. I get, as expected, this output:

    Mangled = _p_p_Ndb not found in zend_types
    Mangled = _p_p_NdbError not found in zend_types
    Mangled = _p_p_NdbTransaction not found in zend_types
    Mangled = _p_p_NdbOperation not found in zend_types
    Mangled = _p_p_NdbScanOperation not found in zend_types
    Mangled = _p_p_NdbRecAttr not found in zend_types
    Mangled = _p_p_NdbOperation not found in zend_types
    Mangled = _p_p_NdbOperation not found in zend_types

    I haven't tried functionality yet - but the segfault is gone, and the resulting C++ file compiles without errors. Sweet.

     
  • Olly Betts

    Olly Betts - 2007-05-26
    • status: open --> closed-fixed
     
  • Olly Betts

    Olly Betts - 2007-05-26

    Logged In: YES
    user_id=14972
    Originator: NO

    I've had a deeper look, and the issue seems to be with wrapping methods and functions returning a pointer to an object (rather than returning an object by value or reference). So the patch seems good and I've applied it to SVN.class

     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks