From: SourceForge.net <no...@so...> - 2010-05-26 05:39:35
|
Bugs item #3006404, was opened at 2010-05-24 12:25 Message generated for change (Comment added) made by wsfulton You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=3006404&group_id=1645 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: php Group: None Status: Closed Resolution: Fixed Priority: 5 Private: No Submitted By: t-Legiaw (t-legiaw) Assigned to: Olly Betts (olly) Summary: PHP: std::string in callback method yields "Resource Id #8" Initial Comment: Symptom: wrong content if a std::string argument is passed to a PHP callback. Example: std::string argument passed to callback: "Greetings from PHP" but an 'echo $msg' from inside the callback prints "Resource id #8" (note: the number - in this case 8 varies) However when the callback is called directly from the PHP main script I am getting the expected result, for example $callback = new PhpCallback(); $callback->run("PHP greetings without beeing used as a callback"); >>> "PHP greetings without beeing used as a callback" ---------------------------------------------------------------------- >Comment By: William Fulton (wsfulton) Date: 2010-05-26 05:39 Message: Olly, this patch fixes the segfault. Probably the undefined behaviour nature of this bug meant it sometimes worked, sometimes not. I thought the php test-suite was 100% passing, but as this one was failing before the patch was applied it might even have been erratic on my machine. ---------------------------------------------------------------------- Comment By: Olly Betts (olly) Date: 2010-05-25 23:41 Message: Yes, we're just missing a typemap. Thanks for spotting that. Fixed in SVN r12053. Should be in the 2.0.0 release. William: I'm not seeing that failure - all the php testsuite passes for me, and trying your command does too... ---------------------------------------------------------------------- Comment By: William Fulton (wsfulton) Date: 2010-05-25 18:27 Message: The very latest svn contains a fix for RUNTOOL, so don't escape the space, use: ~/swig/trunk/Examples/test-suite/php$ make director_string.cpptest RUNTOOL="gdb --args" ---------------------------------------------------------------------- Comment By: William Fulton (wsfulton) Date: 2010-05-25 17:42 Message: This looks related to a failure in the php test-suite on my box. If you run: ~/swig/trunk/Examples/test-suite/php$ make director_string.cpptest RUNTOOL="gdb\ --args" and run in gdb, I get the following stack trace: (gdb) where #0 0x082a4936 in ?? () #1 0x082bdd23 in ?? () #2 0x082cce92 in _zval_ptr_dtor () #3 0x082cecf4 in zend_call_function () #4 0x082cfe7c in call_user_function_ex () #5 0x082cfefb in call_user_function () #6 0x407dd586 in SwigDirector_A::get () from ./director_string.so #7 0x407e1646 in A::get_first () from ./director_string.so #8 0x407e0714 in _wrap_A_get_first () from ./director_string.so #9 0x08314f03 in ?? () #10 0x0830039b in execute () #11 0x083147c6 in ?? () #12 0x0830039b in execute () #13 0x083147c6 in ?? () #14 0x0830039b in execute () #15 0x082daa00 in zend_execute_scripts () #16 0x0828f2da in php_execute_script () #17 0x0835f0a4 in main () SwigDirector_A::get () also returns a const std::string&. ---------------------------------------------------------------------- Comment By: t-Legiaw (t-legiaw) Date: 2010-05-25 16:48 Message: Update: I was able to fix the issue by using a directorin typemap (see also attachement fixed-by-directorin-typemap.tar.gz ) <pre> %typemap(directorin) const std::string & %{ std::cout << $1_name << std::endl; ZVAL_STRINGL($input, $1_name.c_str(), $1_name.length(), 1); %} </pre> and BTW: I am using PHP v5.3.2 ---------------------------------------------------------------------- Comment By: t-Legiaw (t-legiaw) Date: 2010-05-24 12:35 Message: note: the same issue occurs when I change the callback parameter from 'std::string' to 'char *' ---------------------------------------------------------------------- Comment By: t-Legiaw (t-legiaw) Date: 2010-05-24 12:27 Message: Swig Version: 1.3.40 OS Environment: Ubuntu Lucid Lynx g++ v4.4.3 ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=101645&aid=3006404&group_id=1645 |