Bug 1354395 - Always bind symbols at load time for ctypes libraries. r=bsmedberg, a=gchang
authorMike Hommey <mh+mozilla@glandium.org>
Fri, 07 Apr 2017 12:07:32 +0900
changeset 395855 392cffbdb54a0ff8d44bef1ea09d18a14c53e470
parent 395854 ca2f1fee367780ff0e454815e419617e3ea39bb8
child 395856 812a8c51cc980b352c9d5d62f2cca25c8b9f18f9
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbsmedberg, gchang
bugs1354395
milestone54.0a2
Bug 1354395 - Always bind symbols at load time for ctypes libraries. r=bsmedberg, a=gchang When symbols are not bound at load time, missing symbols can lead to NULL derefs or jumps to 0x0 at runtime, crashing the process running the corresponding JS code, which is rather undesirable. So, prevent libraries that have missing symbols to load at all through ctypes.
js/src/ctypes/Library.cpp
--- a/js/src/ctypes/Library.cpp
+++ b/js/src/ctypes/Library.cpp
@@ -143,17 +143,17 @@ Library::Create(JSContext* cx, HandleVal
                 pathStr->length(), pathBytes, &nbytes));
     pathBytes[nbytes] = 0;
   }
 
   libSpec.value.pathname = pathBytes;
   libSpec.type = PR_LibSpec_Pathname;
 #endif
 
-  PRLibrary* library = PR_LoadLibraryWithFlags(libSpec, 0);
+  PRLibrary* library = PR_LoadLibraryWithFlags(libSpec, PR_LD_NOW);
 
 #ifndef XP_WIN
   JS_free(cx, pathBytes);
 #endif
 
   if (!library) {
 #define MAX_ERROR_LEN 1024
     char error[MAX_ERROR_LEN] = "Cannot get error from NSPR.";