Libcouchbase crash


#1

Hi!

I have a problem with the latest libcouchbase. I’m using it with libuv IO plugin. Sometimes I’m expecting crashes.

Steps to reproduce the problem: when I call lcb_cancel_http_request immediately after lcb_make_http_request libcouchbase crashes (see code below) because of req->instance is already NULL.

Any ideas?

static void
on_connected(lcbio_SOCKET *sock, void *arg, lcb_error_t err, lcbio_OSERR syserr)
{
lcb_http_request_t req = arg;
lcbio_CTXPROCS procs;
lcb_settings *settings = req->instance->settings; <<<

Call stack:

on_connected
invoke_request
connection_available
on_connected
cs_handler
C_conncb
connect_callback
uv__stream_connect
uv__stream_io
uv__io_poll
uv_run


#2

I actually experienced something similar a few days ago. Please see if this patch (http://review.couchbase.org/#/c/42614/6/src/http/http.c) fixes your issue.

Also, please try to file an issue on our issue tracker (couchbase.com/issues/browse/CCBC) as well :slight_smile:


#3

Thank you so much for info! Its not crashing now.

I have found another problem no related to the first one, its a memory leak in lcb_http3:

==20343== 2,046 bytes in 1 blocks are definitely lost in loss record 2 of 2

==20343== at 0x4C2ABA0: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)

==20343== by 0x1355FC4: lcb_http3 (http.c:490)

==20343== by 0x135616C: lcb_make_http_request (http.c:547)


#4

Yes, this leak is totally unrelated :frowning: – It’s a simple fix as well - See http://review.couchbase.org/#/c/42697/1/src/http/http.c