Open imperugo opened 8 years ago
I'm suspicious of Promises. Can you verify that there is no crash when it's not wrapped in a promise?
I was thinking the same, but it seems is not related to the promise. I switched the code to ldapjs and it seems to work
ldapjs is a very different beast, it's all javascript-native (and they did a great job of it too).
How did you determine that it isn't related to promises?
because I used the same code without the promise and I got the same error
Can you please post that code, too?
I too am getting this issue, seemingly randomly. I have not yet seen any pattern on the appearance of this bug.
Edit:
I should mention:
When using bind()
the error is:
node: ../deps/uv/src/unix/core.c:888: uv__io_stop: Assertion `loop->watchers[w->fd] == w' failed.
Aborted (core dumped)
When using findandbind()
the error is:
Aborted (core dumped)
I stand corrected, just had the following output from findandbind()
attempt:
node: ../deps/uv/src/unix/core.c:888: uv__io_stop: Assertion `loop->watchers[w->fd] == w' failed.
Aborted (core dumped)
Same Issue in my applicaton.
../deps/uv/src/unix/core.c:878: uv__io_stop: Assertion
loop->watchers[w->fd] == w' failed.`
Node Version v11.9.0
Code: get_contacts: function (req, res) { ldap.bind(user, function (err) { console.log("Error", err); var search_options = { base: "OU=X,OU=X,DC=X,DC=X,DC=X", scope: LDAP.SUBTREE, filter: '(objectClass=contact)', attrs: '*' } ldap.search(search_options, function (err, data) { var data1 = data.map(obj => { for (var key in obj) { if (Array.isArray(obj[key])) { obj[key] = obj[key][0]; } } return obj; }); res.status(200).json(data1); }); }); },
I was experiencing this same crash on 3.1.3
(49bf193) running node v8.14.0
.
The problem is that the module is re-using the handle. In the OnDisconnect
callback, it calls uv_poll_stop to stop watching the handle. Later, in OnConnect
, it sees that the handle is non-NULL and calls uv_poll_stop
again.
We were able to fix this by setting the handle to NULL in OnDisconnect.
diff --git a/LDAPCnx.cc b/LDAPCnx.cc
index 532317f..8325a78 100644
--- a/LDAPCnx.cc
+++ b/LDAPCnx.cc
@@ -219,6 +219,7 @@ void LDAPCnx::OnDisconnect(LDAP *ld, Sockbuf *sb,
LDAPCnx * lc = (LDAPCnx *)ctx->lc_arg;
if (lc->handle) {
uv_poll_stop(lc->handle);
+ lc->handle=NULL;
}
lc->disconnect_callback->Call(0, NULL);
}
#0 0x00007f2739af6e97 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007f2739af8801 in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x00007f2739ae839a in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#3 0x00007f2739ae8412 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
#4 0x000055e58cf29849 in uv__io_stop (loop=<optimized out>, w=w@entry=0x55e58ee94688, events=events@entry=8199) at ../deps/uv/src/unix/core.c:898
#5 0x000055e58cf302f4 in uv__poll_stop (handle=0x55e58ee94620) at ../deps/uv/src/unix/poll.c:103
#6 uv_poll_stop (handle=0x55e58ee94620) at ../deps/uv/src/unix/poll.c:113
#7 0x00007f27345b538b in LDAPCnx::OnConnect (ld=0x55e58ef019f0, sb=<optimized out>, srv=<optimized out>, addr=<optimized out>, ctx=<optimized out>) at ../LDAPCnx.cc:207
#8 0x00007f2734386cf5 in ldap_int_connect_cbs () from /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2
#9 0x00007f2734386fdc in ldap_connect_to_host () from /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2
#10 0x00007f273436f0de in ldap_int_open_connection () from /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2
#11 0x00007f273438434d in ldap_new_connection () from /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2
#12 0x00007f273436e74a in ldap_open_defconn () from /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2
#13 0x00007f2734385908 in ldap_send_initial_request () from /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2
#14 0x00007f2734378b8f in ldap_sasl_bind () from /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2
#15 0x00007f273437adc2 in ldap_simple_bind () from /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2
#16 0x00007f27345b62db in LDAPCnx::Bind (info=...) at /home/gitlab-runner/.cache/node-gyp/8.14.0/include/node/v8.h:9761
#17 0x00007f27345b515f in Nan::imp::FunctionCallbackWrapper (info=...) at ../../nan/nan_callbacks_12_inl.h:174
#18 0x000055e58d017849 in v8::internal::FunctionCallbackArguments::Call(void (*)(v8::FunctionCallbackInfo<v8::Value> const&)) ()
#19 0x000055e58d095a6e in v8::internal::MaybeHandle<v8::internal::Object> v8::internal::(anonymous namespace)::HandleApiCallHelper<false>(v8::internal::Isolate*, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::HeapObject>, v8::internal::Handle<v8::internal::FunctionTemplateInfo>, v8::internal::Handle<v8::internal::Object>, v8::internal::BuiltinArguments) ()
#20 0x000055e58d096941 in v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) ()
Hi, I'm having a strange problem with your library. Basically sometimes (it seems random) calling a search command I've the following error:
I've enabled the debug mode on your library and here the output
It happens both on OSX and Ubuntu Server. Here the code I use to call ldap server (it's Typescript).
It happens with Node 4.x, 5.x and 6.x.
Any hint?