#1126 php proxy class + overloading + std_vector.i causes segfault

php (58)

$ cat example.i
%module example

%include "std_vector.i"
%include "std_string.i"

namespace std {
%template(StringVector) vector<std::string>;

%include example.h


$ cat example.h
#include <string>
#include <vector>

class Job {
void arguments( const std::vector<std::string> & args );
const std::vector<std::string> & arguments() const;

$ swig -php -cppext cxx -c++ -o example_wrap.cc example.i
Segmentation fault

$ swig -noproxy -php -cppext cxx -c++ -o example_wrap.cc example.i

Note that if I rename one of my functions the segfault goes away. Also, using vector<int> works, but vector<std::string> does not.


  • Jay Buffington

    Jay Buffington - 2011-01-27

    I should have mentioned this is swig 2.0.1

  • Olly Betts

    Olly Betts - 2011-02-18
    • status: open --> closed-works-for-me
  • Olly Betts

    Olly Betts - 2011-02-18

    This works for me in SVN trunk.

    I assumed at first it was fixed by r12471 (which is at least superficially similar, and the reason i was testing this bug):


    However undoing that fix I find SWIG doesn't segfault for me either.

    I guess this must have been fixed by another recent change - closing as "works for me" for now, but please reopen if you can reproduce this with current SVN trunk, or with SWIG 2.0.2 once that is released.

  • William Fulton

    William Fulton - 2011-02-18

    For the record, there was a problem as shown below before r12471 was committed, but now okay:

    ==32315== Invalid read of size 4
    ==32315== at 0x805DA49: DohGetattr (base.c:337)
    ==32315== by 0x805E058: DohGetChar (base.c:429)
    ==32315== by 0x80F5F23: PHP::functionWrapper(void*) (php.cxx:1738)
    ==32315== by 0x80C5AC6: Language::memberfunctionHandler(void*) (lang.cxx:1244)
    ==32315== by 0x80F7991: PHP::memberfunctionHandler(void*) (php.cxx:2146)
    ==32315== by 0x80C54BE: Language::functionHandler(void*) (lang.cxx:1067)
    ==32315== by 0x80C657E: Language::cDeclaration(void*) (lang.cxx:977)
    ==32315== by 0x80C85BF: Dispatcher::emit_one(void*) (lang.cxx:121)
    ==32315== by 0x80C89A3: Language::emit_one(void*) (lang.cxx:377)
    ==32315== by 0x80C8159: Dispatcher::emit_children(void*) (lang.cxx:212)
    ==32315== by 0x80C2185: Language::classHandler(void*) (lang.cxx:2448)
    ==32315== by 0x80F6A54: PHP::classHandler(void*) (php.cxx:1982)

  • Olly Betts

    Olly Betts - 2011-02-19
    • status: closed-works-for-me --> closed-fixed
  • Olly Betts

    Olly Betts - 2011-02-19

    Ah, OK - then we were getting a junk pointer instead of NULL there, which just happened to work for reading, but the reporter (due to an environmental difference) was getting a NULL pointer, or one which pointer to an address which couldn't be read from.

    So this is actually fixed by r12471 then.


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

Sign up for the SourceForge newsletter:

No, thanks