Hi,

On Mon, 27 Jun 2011, Pierre Joye wrote:

> Thanks to catch it!
> 
> However this fix sounds wrong to me.
> 
> The SAPI should have getenv implemented as any other web server
> related SAPI. It is also hence why I think this SAPI should really be
> a separate SAPI, always enabled.
> 
> Please revert and try to get the fix in the SAPI itselft instead.

It should be fixed in the SAPI as well of course, but because SAPIs 
don't *have* to specify a getenv handler, I think it's wise to check 
whether the handler exists before using it in htscanner as well. And 
therefore, I don't think it should be reverted.

I do think that for htscanner to work properly, the cli-server should 
also filter out its getenv("DOCUMENT_ROOT") to return the real document 
root otherwise it seems like htscanner will pick a default, but I 
haven't checked or verified that yet.

cheers,
Derick

> On Sun, Jun 26, 2011 at 7:56 PM, Derick Rethans <der...@php.net> wrote:
> > derick                                   Sun, 26 Jun 2011 17:56:58 +0000
> >
> > Revision: http://svn.php.net/viewvc?view=revision&revision=312503
> >
> > Log:
> > - Fixed htscanner to work with the built-in php webserver for requests that
> >  gave a 404. (Derick)
> >
> > It crashed because the CLI server doesn't have sapi_module.getenv defined.
> >
> > The backtrace was when requesting:
> >
> > Program received signal SIGSEGV, Segmentation fault.
> > 0x0000000000000000 in ?? ()
> > (gdb) bt
> > #0  0x0000000000000000 in ?? ()
> > #1  0x00007fffefb67d23 in htscanner_main ()
> >    at /home/derick/dev/php/pecl/htscanner/trunk/htscanner.c:317
> > #2  0x00007fffefb682b6 in sapi_cgi_activate ()
> >    at /home/derick/dev/php/pecl/htscanner/trunk/htscanner.c:428
> > #3  0x00000000008bc748 in sapi_activate_headers_only ()
> >    at /home/derick/dev/php/php-src/branches/PHP_5_4/main/SAPI.c:410
> > #4  0x0000000000a853d3 in php_cli_server_send_error_page (server=0x1279680,
> >    client=0x14e9850, status=404)
> >    at 
> > /home/derick/dev/php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c:1505
> > #5  0x0000000000a8604a in php_cli_server_begin_send_static 
> > (server=0x1279680,
> >    client=0x14e9850)
> >    at 
> > /home/derick/dev/php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c:1626
> > #6  0x0000000000a86dcd in php_cli_server_dispatch (server=0x1279680,
> >    client=0x14e9850)
> >    at 
> > /home/derick/dev/php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c:1738
> > #7  0x0000000000a8735b in php_cli_server_recv_event_read_request (
> >    server=0x1279680, client=0x14e9850)
> >    at 
> > /home/derick/dev/php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c:1877
> > ---Type <return> to continue, or q <return> to quit---
> > #8  0x0000000000a8769d in php_cli_server_do_event_for_each_fd_callback (
> >    _params=0x7fffffffe000, fd=5, event=1)
> >    at 
> > /home/derick/dev/php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c:1963
> > #9  0x0000000000a832ad in php_cli_server_poller_iter_on_active (
> >    poller=0x1279688, opaque=0x7fffffffe000,
> >    callback=0xa874b3 <php_cli_server_do_event_for_each_fd_callback>)
> >    at 
> > /home/derick/dev/php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c:663
> > #10 0x0000000000a8775b in php_cli_server_do_event_for_each_fd (
> >    server=0x1279680,
> >    rhandler=0xa8726f <php_cli_server_recv_event_read_request>,
> >    whandler=0xa87382 <php_cli_server_send_event>)
> >    at 
> > /home/derick/dev/php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c:1989
> > #11 0x0000000000a877a9 in php_cli_server_do_event_loop (server=0x1279680)
> >    at 
> > /home/derick/dev/php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c:1999
> > #12 0x0000000000a879c6 in do_cli_server (argc=5, argv=0x7fffffffe3a8)
> >    at 
> > /home/derick/dev/php/php-src/branches/PHP_5_4/sapi/cli/php_cli_server.c:2072
> > #13 0x0000000000a7cadd in main (argc=5, argv=0x7fffffffe3a8)
> >    at /home/derick/dev/php/php-src/branches/PHP_5_4/sapi/cli/php_cli.c:1361
> > (gdb) frame 1
> > #1  0x00007fffefb67d23 in htscanner_main ()
> >    at /home/derick/dev/php/pecl/htscanner/trunk/htscanner.c:317
> > 317             if (!(doc_root = sapi_module.getenv("DOCUMENT_ROOT", 
> > sizeof("DOCUMENT_ROOT")-1 TSRMLS_CC))) {
> >
> > Bugs: http://pecl.php.net/bugs/0 (unknown)
> >      http://pecl.php.net/bugs/1 (unknown)
> >      http://pecl.php.net/bugs/2 (unknown)
> >      http://pecl.php.net/bugs/3 (unknown)
> >      http://pecl.php.net/bugs/4 (unknown)
> >      http://pecl.php.net/bugs/5 (unknown)
> >      http://pecl.php.net/bugs/6 (unknown)
> >      http://pecl.php.net/bugs/7 (unknown)
> >      http://pecl.php.net/bugs/8 (unknown)
> >      http://pecl.php.net/bugs/9 (unknown)
> >      http://pecl.php.net/bugs/10 (unknown)
> >      http://pecl.php.net/bugs/11 (unknown)
> >      http://pecl.php.net/bugs/12 (unknown)
> >      http://pecl.php.net/bugs/13 (unknown)
> >
> > Changed paths:
> >    U   pecl/htscanner/trunk/htscanner.c
> >
> > Modified: pecl/htscanner/trunk/htscanner.c
> > ===================================================================
> > --- pecl/htscanner/trunk/htscanner.c    2011-06-26 16:30:28 UTC (rev 312502)
> > +++ pecl/htscanner/trunk/htscanner.c    2011-06-26 17:56:58 UTC (rev 312503)
> > @@ -314,7 +314,7 @@
> >        time_t t;
> >        HashTable *ini_entries = NULL;
> >
> > -       if (!(doc_root = sapi_module.getenv("DOCUMENT_ROOT", 
> > sizeof("DOCUMENT_ROOT")-1 TSRMLS_CC))) {
> > +       if (!sapi_module.getenv || !(doc_root = 
> > sapi_module.getenv("DOCUMENT_ROOT", sizeof("DOCUMENT_ROOT")-1 TSRMLS_CC))) {
> >                doc_root = HTG(default_docroot);
> >        }
> >
> >
> >
> > --
> > PECL CVS Mailing List
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> 
> 
> 
> 

-- 
http://derickrethans.nl | http://xdebug.org
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
twitter: @derickr and @xdebug
-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to