Opened 23 months ago

Last modified 14 months ago

#11499 new bug

Loading temp shared object failed in GHCi

Reported by: alfa07 Owned by: trommler
Priority: normal Milestone:
Component: GHCi Version: 7.10.3
Keywords: dynamic linking Cc: trommler, basvandijk, simonmar
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: GHCi crash Test Case:
Blocked By: #11238 Blocking:
Related Tickets: #10458 Differential Rev(s):
Wiki Page:

Description

While trying to launch ghci got the following error:

❯ stack ghci The following GHC options are incompatible with GHCi and have not been passed to it: -threaded -Odph Using main module: 1. Package `line-segment-intersection' component exe:demo with main-is file: /Users/maxim/Dev/ComputationGeometry/LineSegmentIntersection/app/Main.hs Configuring GHCi with the following packages: line-segment-intersection, GLUT, GLUtil, boundingboxes, freetype-simple, freetype2 GHCi, version 7.10.3: http://www.haskell.org/ghc/ :? for help ghc: panic! (the 'impossible' happened)

(GHC version 7.10.3 for x86_64-apple-darwin):

Loading temp shared object failed: dlopen(/var/folders/dz/lm9jncs90nq0vn_5j7xhpg2xqyfj66/T/ghc23900_0/libghc_25.dylib, 5): Symbol not found: _bdf_driver_class

Referenced from: /var/folders/dz/lm9jncs90nq0vn_5j7xhpg2xqyfj66/T/ghc23900_0/libghc_25.dylib Expected in: flat namespace

in /var/folders/dz/lm9jncs90nq0vn_5j7xhpg2xqyfj66/T/ghc23900_0/libghc_25.dylib

Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug

Change History (13)

comment:1 Changed 23 months ago by trommler

Keywords: dynamic linking added
Status: newinfoneeded

Thanks for the report.

This looks like the same issue as #10458, which is fixed in HEAD and the tip of ghc-8.0 but not RC1. Could you try with one of those and report back.

comment:2 Changed 23 months ago by trommler

Cc: trommler added

comment:3 Changed 23 months ago by alfa07

Thank you Peter! I will try, not sure I will be able to make stack work with ghc-8 though.

comment:4 Changed 23 months ago by alfa07

Alas building with ghc-8 didn't help (I have rebuilt it from HEAD and checked that your diff is in): ❯ stack --skip-ghc-check --system-ghc --stack-yaml stack-8.yaml ghci GLUtil-0.8.8: build GLUtil-0.8.8: copy/register line-segment-intersection-0.1.0.0: configure line-segment-intersection-0.1.0.0: build line-segment-intersection-0.1.0.0: copy/register Completed 2 action(s). The following GHC options are incompatible with GHCi and have not been passed to it: -threaded -Odph Using main module: 1. Package `line-segment-intersection' component exe:demo with main-is file: /Users/maxim/Dev/ComputationGeometry/LineSegmentIntersection/app/Main.hs Configuring GHCi with the following packages: line-segment-intersection, GLUT, GLUtil, boundingboxes, freetype-simple, freetype2 GHCi, version 8.1.20160129: http://www.haskell.org/ghc/ :? for help ghc: panic! (the 'impossible' happened)

(GHC version 8.1.20160129 for x86_64-apple-darwin):

Loading temp shared object failed: dlopen(/var/folders/dz/lm9jncs90nq0vn_5j7xhpg2xqyfj66/T/ghc55362_0/libghc_25.dylib, 5): Symbol not found: _bdf_driver_class

Referenced from: /var/folders/dz/lm9jncs90nq0vn_5j7xhpg2xqyfj66/T/ghc55362_0/libghc_25.dylib Expected in: flat namespace

in /var/folders/dz/lm9jncs90nq0vn_5j7xhpg2xqyfj66/T/ghc55362_0/libghc_25.dylib

Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug

comment:5 Changed 23 months ago by alfa07

Using patch as Simon suggested fixes issue after recompiling ghc-7.10.3 with it (rts/Linker.c):

-   hdl = dlopen(dll_name, RTLD_LAZY|RTLD_LOCAL); /* see Note [RTLD_LOCAL] */
+   hdl = dlopen(dll_name, RTLD_LAZY | RTLD_GLOBAL);

comment:6 in reply to:  4 Changed 23 months ago by trommler

I reformatted the compiler output below.

Could you perhaps attach the contents of the directory where you invoke stack so I can have a look and perhaps reproduce?

Replying to alfa07:

Alas building with ghc-8 didn't help (I have rebuilt it from HEAD and checked that your diff is in):

❯ stack  --skip-ghc-check --system-ghc --stack-yaml stack-8.yaml ghci
GLUtil-0.8.8: build
GLUtil-0.8.8: copy/register
line-segment-intersection-0.1.0.0: configure
line-segment-intersection-0.1.0.0: build
line-segment-intersection-0.1.0.0: copy/register
Completed 2 action(s).
The following GHC options are incompatible with GHCi and have not been passed to it: -threaded -Odph
Using main module: 1. Package `line-segment-intersection' component exe:demo with main-is file: /Users/maxim/Dev/ComputationGeometry/LineSegmentIntersection/app/Main.hs
Configuring GHCi with the following packages: line-segment-intersection, GLUT, GLUtil, boundingboxes, freetype-simple, freetype2
GHCi, version 8.1.20160129: http://www.haskell.org/ghc/  :? for help
ghc: panic! (the 'impossible' happened)
  (GHC version 8.1.20160129 for x86_64-apple-darwin):
        Loading temp shared object failed: dlopen(/var/folders/dz/lm9jncs90nq0vn_5j7xhpg2xqyfj66/T/ghc55362_0/libghc_25.dylib, 5): Symbol not found: _bdf_driver_class
  Referenced from: /var/folders/dz/lm9jncs90nq0vn_5j7xhpg2xqyfj66/T/ghc55362_0/libghc_25.dylib
  Expected in: flat namespace
 in /var/folders/dz/lm9jncs90nq0vn_5j7xhpg2xqyfj66/T/ghc55362_0/libghc_25.dylib

Please report this as a GHC bug:  http://www.haskell.org/ghc/reportabug

comment:7 Changed 23 months ago by alfa07

Here is the link to the tar.gzipped folder: https://www.dropbox.com/s/q468h8zvht7w0ln/line-segment-intersection.tar.gz?dl=0 Can't attach it as the size is larger than allowed 256k.

comment:8 in reply to:  5 Changed 23 months ago by trommler

Replying to alfa07:

Using patch as Simon suggested fixes issue after recompiling ghc-7.10.3 with it (rts/Linker.c):

-   hdl = dlopen(dll_name, RTLD_LAZY|RTLD_LOCAL); /* see Note [RTLD_LOCAL] */
+   hdl = dlopen(dll_name, RTLD_LAZY | RTLD_GLOBAL);

This patch breaks ghci/scripts ghci058 at least on Linux and this is to be expected given ELF symbol resolution semantics. See the note referenced in note RTLD_LOCAL for a more detailed explanation.

Did you run ./validate on MacOS with the proposed patch applied?

comment:9 in reply to:  7 ; Changed 23 months ago by trommler

Architecture: x86_64 (amd64)Unknown/Multiple
Blocked By: 11238 added
Operating System: MacOS XUnknown/Multiple
Status: infoneedednew

Replying to alfa07:

Here is the link to the tar.gzipped folder: https://www.dropbox.com/s/q468h8zvht7w0ln/line-segment-intersection.tar.gz?dl=0 Can't attach it as the size is larger than allowed 256k.

Thank you!

I can reproduce the issue on Linux with a GHC that has the #10458 patch:

GHCi, version 7.10.3: http://www.haskell.org/ghc/  :? for help
ghc: panic! (the 'impossible' happened)
  (GHC version 7.10.3 for x86_64-unknown-linux):
        Loading temp shared object failed: /tmp/ghc29316_0/libghc_25.so: undefined symbol: tt_driver_class

I see a different symbol missing but the missing symbol should come from freetype2, too.

Redesign of dynamic linking should fix this. So marking as blocked on that ticket.

comment:10 in reply to:  9 Changed 23 months ago by trommler

Owner: set to trommler

Replying to trommler:

I can reproduce the issue on Linux with a GHC that has the #10458 patch:

GHCi, version 7.10.3: http://www.haskell.org/ghc/  :? for help
ghc: panic! (the 'impossible' happened)
  (GHC version 7.10.3 for x86_64-unknown-linux):
        Loading temp shared object failed: /tmp/ghc29316_0/libghc_25.so: undefined symbol: tt_driver_class

I see a different symbol missing but the missing symbol should come from freetype2, too.

Redesign of dynamic linking should fix this. So marking as blocked on that ticket.

I think I understand what is going on. The undefined symbols are provided by a package that is loaded at startup. Because we need to load (dlopen)with RTLD_LOCAL those symbols are not available in the temporary shared object.

This will be fixed with the new design proposed in #11238.

comment:11 Changed 23 months ago by alfa07

Yeah, I suspected that the easy solution has some catches in the wider world (RTLD_GLOBAL). Thank you for looking at it Peter!

comment:12 Changed 15 months ago by basvandijk

Cc: basvandijk added

comment:13 Changed 14 months ago by simonmar

Cc: simonmar added
Note: See TracTickets for help on using tickets.