Re: Embedding segfault.
| From: | Ben Trafford | Date: | Tue, 05 Jan 2016 11:20:47 +0000 |
| Subject: | Re: Embedding segfault. | ||
| References: | 1 2 3 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-13471@lists.php.net to get a copy of this message | ||
Annnnnd you can ignore me. I wasn't compiling the right file. Adam's fix worked.
Thank you!
--->Ben
On 1/4/2016 3:43 PM, Ben Trafford wrote:
Nope, same problem. If I pull out "php_execute_script(&script TSRMLS_CC);" and replace it with, say, "zend_eval_string()", it works just fine. It's something with the attempt to execute the script. --->Ben On 1/4/2016 1:39 PM, as@php.net wrote:--- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirusDidn't test but--- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirusargc;should probably beargc--;. Adam On Mon, Jan 4, 2016 at 11:00 AM, Ben Trafford <ben@prodigal.ca> wrote:Hello! I'm tinkering with embedding PHP, using Sara Golemon's book as a guide. I'm using the following example from chapter 19.3: #include <stdio.h> #include <sapi/embed/php_embed.h> int main(int argc, char *argv[]) {zend_file_handle script;/* Basic parameter checking */ if (argc <= 1) { fprintf(stderr, "Usage: embed1 filename.php <arguments>\n"); return -1; }/* Set up a File Handle structure */ script.type = ZEND_HANDLE_FP; script.filename = argv[1]; script.opened_path = NULL; script.free_filename = 0; if (!(script.handle.fp = fopen(script.filename, "rb"))) { fprintf(stderr, "Unable to open: %s\n", argv[1]); return -1; }/* Ignore argv[0] when passing to PHP */ argc; argv++;PHP_EMBED_START_BLOCK(argc,argv) php_execute_script(&script TSRMLS_CC); PHP_EMBED_END_BLOCK()return 0;} It's tossing me a segfault, and the trace is coming back to a problem with strlen(), which is usually indicative that something is being passed NULL and shouldn't be. I've narrowed down the issue to php_execute_script(). Now, Sara's examples are a decade old, but I've looked at the guts of PHP, and can't find any reason why that line should be problematic. Any suggestions would be lovely. PS: I've looked around for documentation on PHP's internals, but I can't find any sort of class or function reference. Did I miss something obvious? Thanks! --->Ben --- This email has been checked for viruses by Avast antivirus software. https://www.avast.com/antivirus -- PECL development discussion Mailing List (http://pecl.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php