When enabling collections in the Node.js SDK, a segmentation fault is observed. Upon investigation of the fault, a number of issues appeared to be contributing to this.
The first is that libcouchbase appears to be generating an invalid packet to the cluster in spite of correct inputs. The cluster is brand new with the only modifications being that a default bucket is created, and developer preview options are enabled. I have attached a wireshark capture where the malformed packets are visible at the end (note that
lcb_cmdstore_collection is being invoked with `NULL, 0, "test", 4`, lcb_cmdstore_key with `"f77b7b40_6", 10` and lcb_cmdstore_value with `..., 136`. Note that the incorrectly generated packet is actually proceeded by a completely different issue where the server appears to be returning ERR_INVALID_ARGUMENTS to a GET_COLLECTION_ID request (which might be the root cause of the SDK generating an invalid STORE packet).
In addition to this, the SDK appears to be incorrectly specifying some parts of the error context when this error occurs which is causing a segmentation fault when the sdk attempts to generate error context information on the wrapper side. Here is the relevant portion of the backtrace:
|For Gerrit Dashboard: CCBC-1148|
|119984,6||CCBC-1148: Fix error handling when resolving collections||master||libcouchbase||Status: MERGED||+2||+1|
|120073,3||CCBC-1148: Add NULL checks for enhanced error info||master||libcouchbase||Status: MERGED||+2||+1|