Segfault when assigning a reference variable
| From: | JGM | Date: | Fri, 07 Mar 2014 18:52:37 +0000 |
| Subject: | Segfault when assigning a reference variable | ||
| Groups: | php.pecl.dev | ||
| Request: | Send a blank email to pecl-dev+get-11607@lists.php.net to get a copy of this message | ||
Hi everyone,
I'm trying to implement a virtual method on wxphp that in C++ looks like:
size_t wxInputStream::OnSysRead(void* buffer, size_t bufsize)
so in php this method is implemented as:
public function OnSysRead(&$buffer, $bufsize)
here is some sample php code to grasp the idea:
http://pastebin.com/ZxVQmfs0
The first time the method is called $buffer is assigned the first bytes of
the file correctly but the second time zend engine crashes with a segfault
when trying to modify the $buffer variable, so I'm not sure if it is a zend
bug or me doing silly stuff.
Here the important valgrind output: http://pastebin.com/fhuk6P5r
The extensions C++ code that calls the php OnSysRead method:
https://github.com/wxphp/wxphp/blob/master/src/streams.cpp#L4681
and here is the adaptation of zend_method_call_with* that im using (which
is just a copy paste with minor mod to accept an array of parameters)
https://github.com/wxphp/wxphp/blob/master/wxwidgets.cpp#L574
I'm trying to enable this functionality in order to be able to easily load
images from phar files by using a custom inputstream that reads using one
of the php file functions that supports the stream facilities (in this case
phar://)
I wrote a graphical interface to work with php phar files
https://github.com/jgmdev/phar-gui and I would like
to distribute the
application it self as a phar file which contains its images. Some other
people using wxphp has also requested this functionality and it is an
excellent way of distributing self contained desktop applications developed
with PHP.
Any help is appreciated!