Beginning on October 25th, 2016, Persona will no longer be an option for authentication on BMO. For more details see Persona Deprecated.
Last Comment Bug 504893 - PR_GetLibraryFilePathname with NULL name argument crashes on Mac
: PR_GetLibraryFilePathname with NULL name argument crashes on Mac
Status: NEW
Product: NSPR
Classification: Components
Component: NSPR (show other bugs)
: other
: x86 Mac OS X
: -- normal (vote)
: ---
Assigned To: Wan-Teh Chang
Depends on:
  Show dependency treegraph
Reported: 2009-07-17 12:02 PDT by Meena Vyas
Modified: 2009-07-20 00:38 PDT (History)
0 users
See Also:
Crash Signature:
QA Whiteboard:
Iteration: ---
Points: ---


Description Meena Vyas 2009-07-17 12:02:37 PDT
User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv: Gecko/2009060308 Ubuntu/9.04 (jaunty) Firefox/3.0.11
Build Identifier: 4.7.5

Installed nss nspr using
$sudo /opt/local/bin/port install nss

 char *name = PR_GetLibraryFilePathname(NULL, (PRFuncPtr)_dll_library);
works fine on all platforms but on MAC as NULL is passed to strstr. 
Web Server is calling PR_GetLibraryFilePathname with first argument as NULL.  I get Bus error.

debugger shows stack :

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_PROTECTION_FAILURE at address: 0x00000000
0x969bf7f3 in strstr ()
(gdb) where
#0  0x969bf7f3 in strstr ()
#1  0x000f6345 in PR_GetLibraryFilePathname ()
#2  0x00402fa1 in DllInitialize::DllInitialize (this=0x64dd50) at   dll.cpp:79
#3  0x005b1422 in __static_initialization_and_destruction_0
    (__initialize_p=1, __priority=65535) at dll.cpp:101
#4  0x005b143d in global constructors keyed to _dll_initialize () at
#5  0x8fe12f36 in    __dyld__ZN16ImageLoaderMachO18doModInitFunctionsERKN11ImageLoader11LinkContextE
#6  0x8fe0e7e3 in
   __dyld__ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEj ()
#7  0x8fe0e775 in __dyld__ZN11ImageLoader23recursiveInitializationERKNS_11LinkContextEj ()
#8  0x8fe0e8c9 in    __dyld__ZN11ImageLoader15runInitializersERKNS_11LinkContextE ()
#9  0x8fe04102 in __dyld__ZN4dyld24initializeMainExecutableEv ()
#10 0x8fe07bcf in __dyld__ZN4dyld5_mainEPK11mach_headermiPPKcS5_S5_ ()
#11 0x8fe01872 in __dyld__ZN13dyldbootstrap5startEPK11mach_headeriPPKcl ()
#12 0x8fe01037 in __dyld__dyld_start ()

Reason : 
    PR_GetLibraryFilePathname(const char *name, PRFuncPtr addr)
    #if defined(USE_DLFCN) && (defined(SOLARIS) || defined(FREEBSD) \
            || defined(LINUX) || defined(__GNU__) || defined(__GLIBC__))
    #elif defined(USE_MACH_DYLD)
        char *result;
        const char *image_name;
        int i, count = _dyld_image_count();

        for (i = 0; i < count; i++) {
            image_name = _dyld_get_image_name(i);
            if (strstr(image_name, name) != NULL) {
                result = PR_Malloc(strlen(image_name)+1);
                if (result != NULL) {
                    strcpy(result, image_name);
                return result;

Reproducible: Always
Comment 1 Nelson Bolyard (seldom reads bugmail) 2009-07-17 12:23:49 PDT
How did you encounter this, Meena?
Is there a Sun CR for it?
Comment 2 Wan-Teh Chang 2009-07-17 14:52:41 PDT
The best we can do is to make PR_GetLibraryFilePathname fail
with the PR_INVALID_ARGUMENT_ERROR.  You still need to pass
the library name as the 'name' argument to PR_GetLibraryFilePathname.
Comment 3 Meena Vyas 2009-07-20 00:38:42 PDT
>How did you encounter this
While writing my blog
>Is there a Sun CR for it?
No. Should I file one?

Note You need to log in before you can comment on or make changes to this bug.