Permalink
Browse files

unix: assume that dlopen() clobbers dlerror()

Or rather, don't assume that dlopen() does *not* clobber dlerror().

Joe Ferner reports that loading libjava on OS X sets dlerror() even when
dlopen() succeeds, which makes uv_dlopen() raise an error when it shouldn't.

I haven't been able to reproduce it but it's possible that libjava clobbers
dlerror() by trying (and failing) to load other libraries.

At any rate, Joe confirmed that this patch addresses the issue.

Fixes #462.
  • Loading branch information...
1 parent 4d42af2 commit 1b6843482a3c9834b82b138e8823bc3dae5c7d2d @bnoordhuis bnoordhuis committed Jun 27, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 src/unix/dl.c
View
@@ -34,7 +34,7 @@ int uv_dlopen(const char* filename, uv_lib_t* lib) {
dlerror(); /* Reset error status. */
lib->errmsg = NULL;
lib->handle = dlopen(filename, RTLD_LAZY);
- return uv__dlerror(lib);
+ return lib->handle ? 0 : uv__dlerror(lib);
}

0 comments on commit 1b68434

Please sign in to comment.