Embedding segfault.

From: Date: Mon, 04 Jan 2016 16:00:34 +0000
Subject: Embedding segfault.
Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-13467@lists.php.net to get a copy of this message
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

« previous php.pecl.dev (#13467) next »