node-odbc icon indicating copy to clipboard operation
node-odbc copied to clipboard

Crash in ODBCResult::UV_AfterFetchAll

Open lee-houghton opened this issue 11 years ago • 1 comments

I've been trying to narrow down the cause of some production crashes for a while:

#
# Fatal error in ../deps/v8/src/api.h, line 297
# CHECK(allow_empty_handle || that != __null) failed
#

I finally got a backtrace:

#0  0x000000000095cbae in v8::internal::OS::Abort() ()
#1  0x000000000072490e in V8_Fatal ()
#2  0x00000000006f62b3 in v8::Object::Set(v8::Handle<v8::Value>, v8::Handle<v8::Value>, v8::PropertyAttribute) ()
#3  0x00007fabe2f6cc6a in ODBCResult::UV_AfterFetchAll (work_req=0x7fabd91f7c00, status=<optimized out>) at ../src/odbc_result.cpp:544
#4  0x00000000009c40d1 in uv__work_done ()
#5  0x00000000009ba249 in ?? ()
#6  0x00000000009ba313 in ?? ()
#7  0x00000000009c6f1c in uv__io_poll ()
#8  0x00000000009babac in uv_run ()
#9  0x00000000009692c2 in node::Start(int, char**) ()
#10 0x00007fabe3192eed in __libc_start_main () from /lib/x86_64-linux-gnu/libc.so.6
#11 0x00000000005c0c21 in _start ()

This line 544 actually refers to the master branch in my repository: https://github.com/lee-houghton/node-odbc/blob/master/src/odbc_result.cpp#L544

From the looks of it GetRecordTuple() is returning an empty handle. Presumably this is because GetColumnValue() returned an empty handle due to calling ThrowException. Unfortunately ThrowException is probably a bad thing to do here. Even if UV_AfterFetchAll handled this case, it will result in an exception being thrown when control returns to JavaScript, rather than passed as the err parameter of the callback.

I'm working on a patch for this which will involve properly passing exceptions all the way through to the callback, but it will be for my master branch.

lee-houghton avatar Nov 25 '14 17:11 lee-houghton

The last two commits apparently didn't fully fix it - I had to do this as well: 2606202e7591b2131cb7860ac8b4a50254a03351

lee-houghton avatar Nov 27 '14 13:11 lee-houghton