PHP SDK crashes

When using a custom transcoder implementation, if the transcoder throws an exception, Couchbase makes PHP crash.

See sample script to reproduce the issue:

http://pastebin.com/jYCsQ63t

This is PHP 5.6, with Couchbase SDK 2.1.0 NTS x86, Windows 10 with IIS 10.

Expected behaviour is couchbase internally grabs the exception and wraps it or simply throws it again, but does not make the whole PHP crash.

As a side note, the documentation is quite poor regarding how these transcoders work:

http://developer.couchbase.com/documentation/server/4.0/sdks/php-2.0/op-basics.html

Why does the transcoder return an array with two 0 valued elements?

return array(json_encode($value), 0, 0);

Ok this is real bad… it needs not to be an Exception. If the transcoder issues a notice during during decoding, Couchbase will completely crash PHP.

And you DON’T need to be using a custom transcoder for this… if you store a serialized object using the serialized transcoder, and during deserialization (__wakeup) a notice is issued, the same thing happens.

Please fix this, it is completely breaking the Couchbase-Drupal integration:

Simple repro script:

global $bucket;
global $COUCHBASE_DEFAULT_ENCOPTS;

$COUCHBASE_DEFAULT_ENCOPTS = array(
    'sertype' => COUCHBASE_SERTYPE_PHP,
    'cmprtype' => COUCHBASE_CMPRTYPE_NONE,
    'cmprthresh' => 0,
    'cmprfactor' => 0
);

$cluster = new \CouchbaseCluster('couchbase://127.0.0.1');
$bucket = $cluster->openBucket('default');

$bucket->upsert('cacheid', 'myvalue');

class MyClass {
  
  protected $data;
  
  function __wakeup() {
    global $bucket;
    $this->dadta = $bucket->get('cacheid');
  }
}

$bucket->upsert('cache2', new MyClass());
$class = $bucket->get('cache2');

return;

UPDATE:

This repro script only crashes when the XDEBUG extension is enabled. Yet my experience with other PHP extensions is that if enabling XDEBUG makes something crash there is a very very very big chance that the extension is doing something wrong.

And also from my experience - if the maintainer says “don’t use XDEBUG” - the bug will sooner or later surface without using XDEBUG and then it will be much more difficult to hunt down. You now have a reproducible situation for a crash, don’t miss the opportunity to at least investigate it :slightly_smiling:

Thanks! That might be something for @brett19.

Hey @davidbcn,

What version of XDEBUG are you using? There was a known issue with older versions of XDEBUG which caused compatibility issues with our library.

Cheers, Brett

2.3.3. I believe this is the latest stable release.

Davidben,

We have a maintenance release scheduled for March 1. We were trying to ship this earlier and we will not make the February release train. That should alleviate the issue you’re seeing. We can potentially provide a patch in the interim.

Thanks

Todd Greenstein

Awesome!

I can test before release if that helps. And that would be indeed interesting, although I have tagged stable releases for the Drupal/Couchbase integration, I have not yed pushed that into production but will be doing so during february.