[GHC] #8935: Obscure linker bug leads to crash in GHCi

GHC ghc-devs at haskell.org
Tue May 6 07:40:08 UTC 2014


#8935: Obscure linker bug leads to crash in GHCi
-------------------------------------+------------------------------------
        Reporter:  simonmar          |            Owner:  simonmar
            Type:  bug               |           Status:  infoneeded
        Priority:  high              |        Milestone:  7.8.3
       Component:  Runtime System    |          Version:  7.8.1-rc2
      Resolution:                    |         Keywords:
Operating System:  Unknown/Multiple  |     Architecture:  Unknown/Multiple
 Type of failure:  GHCi crash        |       Difficulty:  Rocket Science
       Test Case:                    |       Blocked By:
        Blocking:                    |  Related Tickets:
-------------------------------------+------------------------------------

Comment (by trommler):

 Adding error handling:
 {{{
   hdl = dlopen(so2, RTLD_LAZY);
   if (hdl == NULL) {
     printf("failed to open libpthread: %s\n", dlerror());
     return 1;
   }
   printf("dlsym(\"libpthread\", \"environ\") = %p\n",
 dlsym(hdl,"environ"));
 }}}
 I get:
 {{{
 &environ = 0x601068, environ = 0x7fffd170d688
 dlsym(deflt, "environ") = 0x601068, *dflt_env = 0x7fffd170d688
 dlsym("libgmp", "environ") = 0x7fcc61a82fd8
 *env = (nil)
 failed to open libpthread: /usr/lib64/libpthread.so: invalid ELF header
 }}}

 `libgmp.so` is not special after all. On openSUSE `libpthread.so` is a
 linker script. `dlopen()` cannot open it and returns `NULL`.
 `RTLD_DEFAULT` is defined as `(void *) 0` so `NULL` so dlsym did not fail
 but return the symbol from the default SO (the program itself).

 Trying `libpthread.so.0` instead shows the same problem as `libgmp.so`.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8935#comment:26>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list