[PCBC-76] Segfaults on view loading Created: 25/Jun/12  Updated: 12/Mar/13  Resolved: 12/Mar/13

Status: Closed
Project: Couchbase PHP client library
Component/s: library
Affects Version/s: 1.1.0-dp2
Fix Version/s: None
Security Level: Public

Type: Bug Priority: Major
Reporter: Michael Nitschinger Assignee: Trond Norbye
Resolution: Fixed Votes: 0
Labels: view
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment: Couchbase Server 2.0 (You are running version 2.0.0 community edition (build-722)) - latest DP release
php-ext-couchbase 1.1.0-dp2
libcouchbase 1.1.0dp6-85 throgh deb repo

Running Ubuntu 12.04


 Description   
Problem Description:
--------------------
The given PHP script was expected to run perfectly fine, instead segfaults.

Version in Use:
---------------
Couchbase Server 2.0 (You are running version 2.0.0 community edition (build-722)) - latest DP release
php-ext-couchbase 1.1.0-dp2
libcouchbase 1.1.0dp6-85 throgh deb repo

The View:
---------
function (doc) {
  if(doc.type == 'session') {
    emit(doc._id, null);
  }
}

Calling PHP Script:
-------------------
<?php
$cb = new Couchbase('127.0.0.1:8091', 'default');
$cb->view('dev_sessions', 'active');
?>

Error Message:
--------------
php: contrib/http_parser/http_parser.c:422: parse_url_char: Assertion `!((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int) _ISspace)' failed.
Aborted (core dumped)

GDB Backtrace:
--------------

#0 0xb7fdd424 in __kernel_vsyscall ()
#1 0xb78041ef in __GI_raise (sig=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#2 0xb7807835 in __GI_abort () at abort.c:91
#3 0xb77fd095 in __assert_fail_base (fmt=0xb79368b8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n",
    assertion=0xb7042710 "!((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int) _ISspace)",
    file=0xb70426ec "contrib/http_parser/http_parser.c", line=422, function=0xb7042f60 "parse_url_char") at assert.c:94
#4 0xb77fd147 in __GI___assert_fail (assertion=0xb7042710 "!((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int) _ISspace)",
    file=0xb70426ec "contrib/http_parser/http_parser.c", line=422, function=0xb7042f60 "parse_url_char") at assert.c:103
#5 0xb703e97f in ?? () from /usr/lib/libcouchbase.so.1
#6 0xb7041015 in ?? () from /usr/lib/libcouchbase.so.1
#7 0xb70337da in libcouchbase_make_couch_request () from /usr/lib/libcouchbase.so.1
#8 0xb73bcb45 in php_couchbase_view_impl (ht=<optimized out>, return_value=0xb779563c, this_ptr=0xb7798e70, oo=1,
    return_value_ptr=<optimized out>, return_value_used=<optimized out>)
    at /home/michael/Downloads/php-ext-couchbase/couchbase.c:2563
#9 0x083d2a85 in execute_internal (execute_data_ptr=0xb741c883, return_value_used=-1216896628)
    at /build/buildd/php5-5.4.4/Zend/zend_execute.c:1480
#10 0xb741c883 in xdebug_execute_internal (current_execute_data=0xb777a18c, return_value_used=1)
    at /build/buildd/xdebug-2.2.0/build-php5/xdebug.c:1482
#11 0x083d1898 in zend_do_fcall_common_helper_SPEC (execute_data=0xb777a18c) at /build/buildd/php5-5.4.4/Zend/zend_vm_execute.h:644
#12 0x0838d605 in execute (op_array=0xb741c491) at /build/buildd/php5-5.4.4/Zend/zend_vm_execute.h:410
#13 0xb741c491 in xdebug_execute (op_array=0xb77991fc) at /build/buildd/xdebug-2.2.0/build-php5/xdebug.c:1390
#14 0x083d1be2 in zend_do_fcall_common_helper_SPEC (execute_data=0xb777a030) at /build/buildd/php5-5.4.4/Zend/zend_vm_execute.h:669
#15 0x0838d605 in execute (op_array=0xb741c491) at /build/buildd/php5-5.4.4/Zend/zend_vm_execute.h:410
#16 0xb741c491 in xdebug_execute (op_array=0xb7794adc) at /build/buildd/xdebug-2.2.0/build-php5/xdebug.c:1390
#17 0x083244b9 in zend_execute_scripts (type=0, retval=0xbfffe124, file_count=0) at /build/buildd/php5-5.4.4/Zend/zend.c:1279
#18 0x082bda3e in php_execute_script (primary_file=0xbfffe124) at /build/buildd/php5-5.4.4/main/main.c:2473
#19 0x083d4593 in do_cli (argc=0, argv=0xbffff4c5) at /build/buildd/php5-5.4.4/sapi/cli/php_cli.c:988
#20 0x0806aefe in main (argc=2, argv=0xbffff344) at /build/buildd/php5-5.4.4/sapi/cli/php_cli.c:1361

 Comments   
Comment by Matt Ingenthron [ 02/Jul/12 ]
Laruence: Can you have a quick look at this? Is this something simple?
Comment by Matt Ingenthron [ 02/Jul/12 ]
Another note from a user:
i'm gonna guess that's what's really happening is a buffer overrun somewhere else which then clobbers' http_parser's internal state
because i've been using http_parser for a long time and i've never seen it crap like that
Comment by Michael Nitschinger [ 03/Aug/12 ]
I think this can be closed, it works with a recent build of php-ext-couchbase with the latest libcouchbase (also, this ticket was opened against the unstable branch and it will be fixed for the final relase).
Comment by Sergey Avseyev [ 12/Mar/13 ]
Looks like it still relevant

<jgillmanjr> Greetings. I'm not sure if this would be the place to get further information, but when trying to make a view call using the PHP client, I get this as an error: php: contrib/http_parser/http_parser.c:422: parse_url_char: Assertion `!((*__ctype_b_loc ())[(int) ((ch))] & (unsigned short int) _ISspace)' failed.
<jgillmanjr> Googling only shows a bug thread that indicates this has been resolved. I'm running the 2.0.4 version of the library and just recompiled the latest source version of the php client

"php -i" output (http://dpaste.org/WGcNG/raw/)
couchbase

couchbase support => enabled
version => 1.1.2
json support => yes
fastlz support => yes
zlib support => yes

Directive => Local Value => Master Value
couchbase.compression_factor => 1.3 => 1.3
couchbase.compression_threshold => 2000 => 2000
couchbase.compressor => none => none
couchbase.durability_default_poll_interval => 100000 => 100000
couchbase.durability_default_timeout => 40000000 => 40000000
couchbase.serializer => php => php
couchbase.view_timeout => 75 => 75

php code (http://dpaste.org/WCs3Z/raw/)
<?php
        $cb = new Couchbase("couchbase1:8091", "customer_mrc", "customer_mrc", "customer_mrc");

        $view = $cb->view("mrc", "Index Latest MRC");

        print_r($view);
?>
Comment by Sergey Avseyev [ 12/Mar/13 ]
I think it because view named with spaces "Index Latest MRC"
Comment by Sergey Avseyev [ 12/Mar/13 ]
closing this back. I've created another ticket PCBC-211




Generated at Fri Aug 22 19:14:33 CDT 2014 using JIRA 5.2.4#845-sha1:c9f4cc41abe72fb236945343a1f485c2c844dac9.