
#8974: 64 bit windows executable built with ghc-7.9.20140405+LLVM segfaults ------------------------------------+---------------------------------- Reporter: awson | Owner: Type: bug | Status: new Priority: high | Milestone: 7.8.3 Component: Compiler (LLVM) | Version: 7.9 Resolution: | Keywords: Operating System: Windows | Architecture: x86_64 (amd64) Type of failure: Runtime crash | Difficulty: Unknown Test Case: | Blocked By: Blocking: | Related Tickets: ------------------------------------+---------------------------------- Comment (by awson): Well, I've found the source of this bug. It turned out, windows does not like 64-bit offsets, perhaps, this is PE32+'s painful legacy. Here is the difference between segfaulting and working (manually created) code: {{{ --- T8947.s 2014-04-21 14:02:47.240488500 +0400 +++ T8947m.s 2014-04-21 15:22:41.951320900 +0400 @@ -85,7 +85,8 @@ .globl T8947_t1_info_itable # @T8947_t1_info_itable .align 8 T8947_t1_info_itable: - .quad S1i6_srt-T8947_t1_info + .long S1i6_srt-T8947_t1_info + .long 0 .quad 4294967299 # 0x100000003 .quad 0 # 0x0 .quad 64424509455 # 0xf0000000f @@ -145,7 +146,8 @@ .text .align 8 # @c1hV_info_itable c1hV_info_itable: - .quad S1i6_srt-c1hV_info + .long S1i6_srt-c1hV_info + .long 0 .quad 0 # 0x0 .quad 47244640288 # 0xb00000020 @@ -167,7 +169,8 @@ .globl T8947_t8947_info_itable # @T8947_t8947_info_itable .align 8 T8947_t8947_info_itable: - .quad (S1i6_srt-T8947_t8947_info)+16 + .long (S1i6_srt-T8947_t8947_info)+16 + .long 0 .quad 4294967299 # 0x100000003 .quad 0 # 0x0 .quad 4294967311 # 0x10000000f }}} Bad data are generated by the following llvm code: {{{ ... @T8947_t1_info_itable = constant %T8947_t1_entry_struct<{i64 add (i64 sub (i64 ptrtoint (i8* @S1i6_srt$alias to i64),i64 ptrtoint (void (i64*, i64*, i64*, i64, i64, i64, i64, i64, i64, i64)* @T8947_t1_info to i64)),i64 0), i64 4294967299, i64 0, i64 64424509455}>, section "X98A__STRIP,__me3", align 8 ... @c1hV_info_itable = internal constant %c1hV_entry_struct<{i64 add (i64 sub (i64 ptrtoint (i8* @S1i6_srt$alias to i64),i64 ptrtoint (void (i64*, i64*, i64*, i64, i64, i64, i64, i64, i64, i64)* @c1hV_info to i64)),i64 0), i64 0, i64 47244640288}>, section "X98A__STRIP,__me5", align 8 ... @T8947_t8947_info_itable = constant %T8947_t8947_entry_struct<{i64 add (i64 sub (i64 ptrtoint (i8* @S1i6_srt$alias to i64),i64 ptrtoint (void (i64*, i64*, i64*, i64, i64, i64, i64, i64, i64, i64)* @T8947_t8947_info to i64)),i64 16), i64 4294967299, i64 0, i64 4294967311}>, section "X98A__STRIP,__me7", align 8 ... }}} But don't quite understand where in the GHC code shall I intervene precisely to fix it. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8974#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler