[GHC] #9907: "Unknown PEi386 section name `.text$printf'" error in GHCi on Windows

#9907: "Unknown PEi386 section name `.text$printf'" error in GHCi on Windows ----------------------------------+------------------------------------- Reporter: mmikolajczyk | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.8.3 Keywords: | Operating System: Windows Architecture: x86_64 (amd64) | Type of failure: GHCi crash Difficulty: Unknown | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: ----------------------------------+------------------------------------- I work on a Haskell library interfacing with foreign C++ library. While trying to use it in GHCi on Windows 8.1 64bit, I encountered an error message that said: {{{ <loading other libraries> Loading package library-0.1.0.0 ... <interactive>: Unknown PEi386 section name ` .text$_ZNSt6vectorIcSaIcEED1Ev' (while processing: c:\path\to\file.o) ghc.exe: panic! (the 'impossible' happened) (GHC version 7.8.3 for i386-unknown-mingw32): loadObj "C:\\path\\to\\file.o": failed Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} I've prepared a minimal example triggering this bug and attached it to this bug report. On Linux (Arch 64bit), after cabal build and cabal repl it behaves as intended: {{{ GHCi, version 7.8.3: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. Loading object (static) dist/build/cbits/ex.o ... done final link ... done [1 of 1] Compiling Example ( Example.hs, interpreted ) Ok, modules loaded: Example. λ: foo Test }}} However, on Windows 8.1 it crashes while loading object file: {{{ GHCi, version 7.8.3: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Loading package base ... linking ... done. Loading object (static) dist\build\cbits\ex.o ... ghc.exe: Unknown PEi386 sectio n name `.text$printf' (while processing: dist\build\cbits\ex.o) ghc.exe: panic! (the 'impossible' happened) (GHC version 7.8.3 for i386-unknown-mingw32): loadObj "dist\\build\\cbits\\ex.o": failed Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug }}} Crashing in GHCi means that I cannot use it with programs that contain TH splices, what is important for me. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9907 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9907: "Unknown PEi386 section name `.text$printf'" error in GHCi on Windows ---------------------------------+----------------------------------------- Reporter: mmikolajczyk | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.8.3 Resolution: | Keywords: Operating System: Windows | Architecture: x86_64 (amd64) Type of failure: GHCi crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Revisions: ---------------------------------+----------------------------------------- Comment (by kdmadej): I've encountered a similar error while working on windows myself. Checked with the attached example and it also crashes. Is there a chance this matter will get looked into? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9907#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9907: "Unknown PEi386 section name `.text$printf'" error in GHCi on Windows -------------------------------------+------------------------------------- Reporter: mmikolajczyk | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.8.3 Resolution: | Keywords: Operating System: Windows | Architecture: x86_64 Type of failure: GHCi crash | (amd64) Blocked By: | Test Case: Related Tickets: #7103, #10051 | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Changes (by rwbarton): * related: => #7103, #10051 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9907#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9907: "Unknown PEi386 section name `.text$printf'" error in GHCi on Windows -------------------------------------+------------------------------------- Reporter: mmikolajczyk | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.8.3 Resolution: | Keywords: Operating System: Windows | Architecture: x86_64 Type of failure: GHCi crash | (amd64) Blocked By: | Test Case: Related Tickets: #7103, #10051 | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by danilo2): Replying to [comment:2 rwbarton]: Hello rwbarton! I'm working with both kdmadej as well as mmikolajczyk and this bug is some kind of blocker for us. I would love to ask you if can we discuss possible solutions / workarounds to make our use case work? We would like to collaborate with you guys as strong as we are able, we can try to investigate it further if you provide any hints for us - anything. As a side-note: we are using GHCi (or more strictly GHC API) under the hood and GHCi is some kind of interpreter our product bases on - because of that and because the release deadline is in very narrow time from now, we are worrying about that issue. I would be very thankful for any help! :) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9907#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9907: "Unknown PEi386 section name `.text$printf'" error in GHCi on Windows -------------------------------------+------------------------------------- Reporter: mmikolajczyk | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.8.3 Resolution: | Keywords: Operating System: Windows | Architecture: x86_64 Type of failure: GHCi crash | (amd64) Blocked By: | Test Case: Related Tickets: #7103, #10051 | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by rwbarton):
I would love to ask you if can we discuss possible solutions / workarounds to make our use case work?
Use Linux? :) Sorry, I have no Windows experience and no access to a Windows machine. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9907#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9907: "Unknown PEi386 section name `.text$printf'" error in GHCi on Windows -------------------------------------+------------------------------------- Reporter: mmikolajczyk | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.8.3 Resolution: | Keywords: Operating System: Windows | Architecture: x86_64 Type of failure: GHCi crash | (amd64) Blocked By: | Test Case: Related Tickets: #7103, #10051 | Blocking: | Differential Revisions: -------------------------------------+------------------------------------- Comment (by danilo2): Replying to [comment:4 rwbarton]:
Use Linux? :) Sorry, I have no Windows experience and no access to a Windows machine.
I hope that was not offensiwe (although I feel it was). We cannot convert all the people we address the software to use Linux, can we? Additional I thought GHC is ment to be serious - cross-platform compiler, so I think solving this bug is somewhat important for everybody. We've got some windows expirence and people that can help you (but they are not haskellers) additional I can provide you any time remote machine on Amazon with everything configured - you could connect to it and check the things out. We will help you as much as we can also - what do you think? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9907#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9907: "Unknown PEi386 section name `.text$printf'" error in GHCi on Windows -------------------------------------+------------------------------------- Reporter: mmikolajczyk | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.8.3 Resolution: | Keywords: Operating System: Windows | Architecture: x86_64 Type of failure: GHCi crash | (amd64) Blocked By: | Test Case: Related Tickets: #7103, #10051, | Blocking: #7056, #8546 | Differential Revisions: -------------------------------------+------------------------------------- Changes (by thoughtpolice): * related: #7103, #10051 => #7103, #10051, #7056, #8546 Comment: (Adding related tickets.) Basically, the check for these debugging symbol sections is a real hack. See https://github.com/ghc/ghc/blob/master/rts/Linker.c#L4388-L4407 for the relevant code. GHC tries to ignore sections containing debugging information in its own linker code, but this has proven pretty painful for us in the long run, because MinGW/binutils changes mean we frequently hit sections we didn't know about before, so things like this fail (even though those sections are almost certainly harmless). I suspect the best thing to do honestly is remove this code, or at least rework it. It is probably better to add a message which is printed out when linked with `-debug` (and using a debugging runtime flag) about what unknown sections we found, instead of always erroring out when an unknown section is found like we do today. This fix would be pretty simple and also fix the root issue of most of the related tickets (since they're basically all dupes of different colors). If someone would submit a (tested!) patch, that would be excellent! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9907#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9907: "Unknown PEi386 section name `.text$printf'" error in GHCi on Windows -------------------------------------+------------------------------------- Reporter: mmikolajczyk | Owner: Phyx- Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 7.8.3 Resolution: | Keywords: Operating System: Windows | Architecture: x86 Type of failure: GHCi crash | Test Case: Blocked By: | Blocking: Related Tickets: #7103, #10051, | Differential Revisions: #7056, #8546 | -------------------------------------+------------------------------------- Changes (by Phyx-): * owner: => Phyx- * architecture: x86_64 (amd64) => x86 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9907#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9907: "Unknown PEi386 section name `.text$printf'" error in GHCi on Windows -------------------------------------+------------------------------------- Reporter: mmikolajczyk | Owner: Phyx- Type: bug | Status: patch Priority: normal | Milestone: Component: GHCi | Version: 7.8.3 Resolution: | Keywords: Operating System: Windows | Architecture: x86 Type of failure: GHCi crash | Test Case: Blocked By: | Blocking: Related Tickets: #7103, #10051, | Differential Revisions: D671 #7056, #8546 | -------------------------------------+------------------------------------- Changes (by Phyx-): * status: new => patch * differential: => D671 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9907#comment:8 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9907: "Unknown PEi386 section name `.text$printf'" error in GHCi on Windows
-------------------------------------+-------------------------------------
Reporter: mmikolajczyk | Owner: Phyx-
Type: bug | Status: patch
Priority: normal | Milestone:
Component: GHCi | Version: 7.8.3
Resolution: | Keywords:
Operating System: Windows | Architecture: x86
Type of failure: GHCi crash | Test Case:
Blocked By: | Blocking:
Related Tickets: #7103, #10051, | Differential Revisions: D671
#7056, #8546 |
-------------------------------------+-------------------------------------
Comment (by Austin Seipp

#9907: "Unknown PEi386 section name `.text$printf'" error in GHCi on Windows -------------------------------------+------------------------------------- Reporter: mmikolajczyk | Owner: Phyx- Type: bug | Status: merge Priority: normal | Milestone: 7.10.1 Component: GHCi | Version: 7.8.3 Resolution: | Keywords: Operating System: Windows | Architecture: x86 Type of failure: GHCi crash | Test Case: Blocked By: | Blocking: Related Tickets: #7103, #10051, | Differential Revisions: Phab:D671 #7056, #8546 | -------------------------------------+------------------------------------- Changes (by thoughtpolice): * status: patch => merge * differential: D671 => Phab:D671 * milestone: => 7.10.1 Comment: Merged, thanks! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9907#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9907: "Unknown PEi386 section name `.text$printf'" error in GHCi on Windows -------------------------------------+------------------------------------- Reporter: mmikolajczyk | Owner: Phyx- Type: bug | Status: closed Priority: normal | Milestone: 7.10.1 Component: GHCi | Version: 7.8.3 Resolution: fixed | Keywords: Operating System: Windows | Architecture: x86 Type of failure: GHCi crash | Test Case: Blocked By: | Blocking: Related Tickets: #7103, #10051, | Differential Revisions: Phab:D671 #7056, #8546 | -------------------------------------+------------------------------------- Changes (by thoughtpolice): * status: merge => closed * resolution: => fixed Comment: Merged to `ghc-7.10` (via ad628657cd56362964d17677728f4ae4d6868613). -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9907#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9907: "Unknown PEi386 section name `.text$printf'" error in GHCi on Windows -------------------------------------+------------------------------------- Reporter: mmikolajczyk | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.10.1 Component: GHCi | Version: 7.8.3 Resolution: | Keywords: Operating System: Windows | Architecture: x86 Type of failure: GHCi crash | Test Case: Blocked By: | Blocking: Related Tickets: #7103, #10051, | Differential Revisions: Phab:D671 #7056, #8546 | -------------------------------------+------------------------------------- Changes (by ezyang): * owner: Phyx- => * status: closed => new * resolution: fixed => Comment: I am reopening this ticket, because by suppressing these errors we have opened up users to a more pernicious situation: GHC silently ignores a section it doesn't understand (failing to map it into memory) when a program ACTUALLY needs it to function. Previously, it was pretty obvious that something bad had happened and it was because GHC didn't support a section, but now the errors can be a lot more obscure, e.g. #10672 and #10563. Is there any reason we can't take an alternate approach, where by default we attempt to map in ALL sections in an object file, except ones we've specifically blacklisted? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9907#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9907: "Unknown PEi386 section name `.text$printf'" error in GHCi on Windows -------------------------------------+------------------------------------- Reporter: mmikolajczyk | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.10.1 Component: GHCi | Version: 7.8.3 Resolution: | Keywords: Operating System: Windows | Architecture: x86 Type of failure: GHCi crash | Test Case: Blocked By: | Blocking: Related Tickets: #7103, #10051, | Differential Revisions: Phab:D671 #7056, #8546 | -------------------------------------+------------------------------------- Changes (by Phyx-): * cc: Phyx- (added) Comment: I have been trying something similar, but then I encountered another error: `unhandled PEi386 relocation type 3`. Looking at the code there is indeed no case for relocation type 3 which unless I'm mistaken is: IMAGE_REL_AMD64_ADDR32NB 0x0003 The 32-bit address without an image base (RVA). But curiously while trying to understand what the linker is doing (and I may have the wrong idea since I'm new to this part) I see under the `x86_64` cases this `case 17: /* R_X86_64_32S */`. However in the PE doc I can't find any relocation type `0x0011`. So am I looking at the wrong place or should this have been `0x0003`? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9907#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9907: "Unknown PEi386 section name `.text$printf'" error in GHCi on Windows -------------------------------------+------------------------------------- Reporter: mmikolajczyk | Owner: Type: bug | Status: new Priority: normal | Milestone: 7.10.1 Component: GHCi | Version: 7.8.3 Resolution: | Keywords: Operating System: Windows | Architecture: x86 Type of failure: GHCi crash | Test Case: Blocked By: | Blocking: Related Tickets: #7103, #10051, | Differential Revisions: Phab:D671 #7056, #8546 | -------------------------------------+------------------------------------- Changes (by ezyang): * cc: igloo (added) Comment: Ian Lyangh would be able to say better, having authored the patch, but what I think happened was, because the PE spec doesn't actually say how to process relocations, the code was written by cross-referencing against relocations in ELF. But it does look like R_X86_64_32S was given the wrong constant... -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9907#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9907: "Unknown PEi386 section name `.text$printf'" error in GHCi on Windows -------------------------------------+------------------------------------- Reporter: mmikolajczyk | Owner: Phyx- Type: bug | Status: new Priority: normal | Milestone: 7.10.1 Component: GHCi | Version: 7.8.3 Resolution: | Keywords: Operating System: Windows | Architecture: x86 Type of failure: GHCi crash | Test Case: Blocked By: | Blocking: Related Tickets: #7103, #10051, | Differential Revisions: Phab:D671 #7056, #8546 | -------------------------------------+------------------------------------- Changes (by Phyx-): * owner: => Phyx- -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9907#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9907: "Unknown PEi386 section name `.text$printf'" error in GHCi on Windows -------------------------------------+------------------------------------- Reporter: mmikolajczyk | Owner: Phyx- Type: bug | Status: new Priority: normal | Milestone: 7.10.3 Component: GHCi | Version: 7.8.3 Resolution: | Keywords: Operating System: Windows | Architecture: x86 Type of failure: GHCi crash | Test Case: Blocked By: | Blocking: Related Tickets: #7103, #10051, | Differential Revisions: Phab:D671 #7056, #8546 | -------------------------------------+------------------------------------- Changes (by thoughtpolice): * milestone: 7.10.1 => 7.10.3 Comment: Moving to 7.10.3, in case there's a fix. Thanks Phyx-! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9907#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9907: "Unknown PEi386 section name `.text$printf'" error in GHCi on Windows -------------------------------------+------------------------------------- Reporter: mmikolajczyk | Owner: Phyx- Type: bug | Status: new Priority: normal | Milestone: 7.10.3 Component: GHCi | Version: 7.8.3 Resolution: | Keywords: Operating System: Windows | Architecture: x86 Type of failure: GHCi crash | Test Case: Blocked By: | Blocking: Related Tickets: #7103, #10051, | Differential Revisions: Phab:D671 #7056, #8546 | -------------------------------------+------------------------------------- Comment (by Phyx-): @thoughtpolice Yes there will be a fix :) I have changed the code to identify most of the sections based on the flags in the PE file instead of the section names. So we don't have to keep a list of white-listed sections, so it should be much more resilient to changes. The only sections still being ignored by names are a few debugging ones, but it's fine since those are reserved names and currently we don't do debug section relocations. I'm just trying to find where the constant 17 comes from, but from looking at the generated .s files, I think this might be a bug in GAS. I'll submit a diff this weekend after I finish checking if the related bug reports are also fixed :) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9907#comment:17 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9907: "Unknown PEi386 section name `.text$printf'" error in GHCi on Windows -------------------------------------+------------------------------------- Reporter: mmikolajczyk | Owner: Phyx- Type: bug | Status: patch Priority: normal | Milestone: 7.10.3 Component: GHCi | Version: 7.8.3 Resolution: | Keywords: Operating System: Windows | Architecture: x86 Type of failure: GHCi crash | Test Case: Blocked By: | Blocking: Related Tickets: #7103, #10051, | Differential Revisions: Phab:D1244 #7056, #8546 | -------------------------------------+------------------------------------- Changes (by Phyx-): * status: new => patch * differential: Phab:D671 => Phab:D1244 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9907#comment:18 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#9907: "Unknown PEi386 section name `.text$printf'" error in GHCi on Windows
-------------------------------------+-------------------------------------
Reporter: mmikolajczyk | Owner: Phyx-
Type: bug | Status: patch
Priority: normal | Milestone: 7.10.3
Component: GHCi | Version: 7.8.3
Resolution: | Keywords:
Operating System: Windows | Architecture: x86
Type of failure: GHCi crash | Test Case:
Blocked By: | Blocking:
Related Tickets: #7103, #10051, | Differential Rev(s): Phab:D1244
#7056, #8546 |
-------------------------------------+-------------------------------------
Comment (by Thomas Miedema

#9907: "Unknown PEi386 section name `.text$printf'" error in GHCi on Windows -------------------------------------+------------------------------------- Reporter: mmikolajczyk | Owner: Phyx- Type: bug | Status: closed Priority: normal | Milestone: 7.10.3 Component: GHCi | Version: 7.8.3 Resolution: fixed | Keywords: Operating System: Windows | Architecture: x86 Type of failure: GHCi crash | Test Case: Blocked By: | Blocking: Related Tickets: #7103, #10051, | Differential Rev(s): Phab:D1244 #7056, #8546 | -------------------------------------+------------------------------------- Changes (by thomie): * status: patch => closed * resolution: => fixed Comment: Should be really fixed now. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/9907#comment:20 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC