简体   繁体   English

在php扩展内调用方法时出现分段错误

[英]Segmentation fault on method calling inside a php extension

I am trying to pass some data to an object stored in an zval, inside a php extension with this code, and I receive segmentation fault error 我正在尝试使用此代码将一些数据传递到php扩展内的zval中存储的对象,并且收到分段错误错误

[core:notice] [pid 8645] AH00052: child pid 8649 exit signal Segmentation fault (11) [core:notice] [pid 8645] AH00052:子pid 8649退出信号分段错误(11)

Does anyone can help me to understand why I get this error and what is the right way to call an object method? 有谁能帮助我理解为什么会出现此错误,以及调用对象方法的正确方法是什么?

thanks! 谢谢!

    //create zval with the data
    zval *zbuffer;
    MAKE_STD_ZVAL(zbuffer);
    ZVAL_STRINGL(zbuffer, WS_G(buffer), WS_G(bufferLen), 1);

    ///push data in object
    zval *retval_ptr;
    zend_call_method( *WS_G(zobj), ce, NULL, "push",  strlen("push"),  &retval_ptr, 1, zbuffer, NULL TSRMLS_CC );

It seems that the problem were on how I was creating the zbuffer ZVAL the right code is: 看来问题出在我如何创建zbuffer ZVAL上,正确的代码是:

    zval *zbuffer;
    MAKE_STD_ZVAL(zbuffer);
    Z_TYPE_P(zbuffer) = IS_STRING;
    Z_STRVAL_P(zbuffer) = WS_G(buffer);
    Z_STRLEN_P(zbuffer) = WS_G(bufferLen);

Thanks! 谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM