[GHC] #8242: Infinite loop with addCFinalizerToWeak

#8242: Infinite loop with addCFinalizerToWeak --------------------------+------------------------------------------------ Reporter: akio | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: | Version: 7.6.3 Runtime System | Operating System: Linux Keywords: | Type of failure: Incorrect result at runtime Architecture: x86_64 | Test Case: (amd64) | Blocking: Difficulty: | Unknown | Blocked By: | Related Tickets: | --------------------------+------------------------------------------------ (moved from #8236 ) When I compile the attached program with {{{-threaded -O2}}} and run it, it does not terminate. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8242 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8242: Infinite loop with addCFinalizerToWeak ------------------------------------------------+-------------------------- Reporter: akio | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 7.6.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Incorrect result at runtime | (amd64) Test Case: | Difficulty: Blocking: | Unknown | Blocked By: | Related Tickets: ------------------------------------------------+-------------------------- Changes (by kazu-yamamoto): * cc: kazu@… (added) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8242#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8242: Infinite loop with addCFinalizerToWeak ------------------------------------------------+-------------------------- Reporter: akio | Owner: Type: bug | Status: patch Priority: normal | Milestone: Component: Runtime System | Version: 7.6.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Incorrect result at runtime | (amd64) Test Case: | Difficulty: Blocking: | Unknown | Blocked By: | Related Tickets: ------------------------------------------------+-------------------------- Changes (by akio): * status: new => patch -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8242#comment:2 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8242: Infinite loop with addCFinalizerToWeak ------------------------------------------------+-------------------------- Reporter: akio | Owner: Type: bug | Status: patch Priority: normal | Milestone: Component: Runtime System | Version: 7.6.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Incorrect result at runtime | (amd64) Test Case: | Difficulty: Blocking: | Unknown | Blocked By: | Related Tickets: ------------------------------------------------+-------------------------- Comment (by kazu-yamamoto): In my 32bit Linux, your patch does not fix the infinite loop of the test case. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8242#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8242: Infinite loop with addCFinalizerToWeak ------------------------------------------------+-------------------------- Reporter: akio | Owner: Type: bug | Status: patch Priority: normal | Milestone: Component: Runtime System | Version: 7.6.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Incorrect result at runtime | (amd64) Test Case: | Difficulty: Blocking: | Unknown | Blocked By: | Related Tickets: ------------------------------------------------+-------------------------- Comment (by kazu-yamamoto): Andi confirmed that Akio's patch fixes this problem on 64bit Linux. Just in case, I will try this both on 32bit and 64bit Linux. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8242#comment:4 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8242: Infinite loop with addCFinalizerToWeak ------------------------------------------------+-------------------------- Reporter: akio | Owner: Type: bug | Status: patch Priority: normal | Milestone: Component: Runtime System | Version: 7.6.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Incorrect result at runtime | (amd64) Test Case: | Difficulty: Blocking: | Unknown | Blocked By: | Related Tickets: ------------------------------------------------+-------------------------- Comment (by akio): I haven't been able to reproduce Kazu's observation. In my chroot environment (with a 64-bit kernel and a 32-bit user space), my patch does seem to fix the infinite loop issue. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8242#comment:5 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8242: Infinite loop with addCFinalizerToWeak ------------------------------------------------+-------------------------- Reporter: akio | Owner: Type: bug | Status: patch Priority: normal | Milestone: Component: Runtime System | Version: 7.6.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Incorrect result at runtime | (amd64) Test Case: | Difficulty: Blocking: | Unknown | Blocked By: | Related Tickets: ------------------------------------------------+-------------------------- Comment (by kazu-yamamoto): I confirmed that Akio's patch fixes the problem both on 32bit and 64bit Linux. Probably I made a mistake before. I hope this patch will be accepted by GHC HQ. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8242#comment:6 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8242: Infinite loop with addCFinalizerToWeak ------------------------------------------------+-------------------------- Reporter: akio | Owner: Type: bug | Status: patch Priority: normal | Milestone: Component: Runtime System | Version: 7.6.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Incorrect result at runtime | (amd64) Test Case: | Difficulty: Blocking: | Unknown | Blocked By: | Related Tickets: ------------------------------------------------+-------------------------- Comment (by thoughtpolice): Great test and find! Much appreciated. I'll get around to merging this soon... -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8242#comment:7 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8242: Infinite loop with addCFinalizerToWeak
------------------------------------------------+--------------------------
Reporter: akio | Owner:
Type: bug | Status: patch
Priority: normal | Milestone:
Component: Runtime System | Version: 7.6.3
Resolution: | Keywords:
Operating System: Linux | Architecture: x86_64
Type of failure: Incorrect result at runtime | (amd64)
Test Case: | Difficulty:
Blocking: | Unknown
| Blocked By:
| Related Tickets:
------------------------------------------------+--------------------------
Comment (by Austin Seipp

#8242: Infinite loop with addCFinalizerToWeak
------------------------------------------------+--------------------------
Reporter: akio | Owner:
Type: bug | Status: patch
Priority: normal | Milestone:
Component: Runtime System | Version: 7.6.3
Resolution: | Keywords:
Operating System: Linux | Architecture: x86_64
Type of failure: Incorrect result at runtime | (amd64)
Test Case: | Difficulty:
Blocking: | Unknown
| Blocked By:
| Related Tickets:
------------------------------------------------+--------------------------
Comment (by Austin Seipp

#8242: Infinite loop with addCFinalizerToWeak ------------------------------------------------+-------------------------- Reporter: akio | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Runtime System | Version: 7.6.3 Resolution: fixed | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Incorrect result at runtime | (amd64) Test Case: | Difficulty: Blocking: | Unknown | Blocked By: | Related Tickets: ------------------------------------------------+-------------------------- Changes (by thoughtpolice): * status: patch => closed * resolution: => fixed Comment: Merged. Thanks! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8242#comment:10 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8242: Infinite loop with addCFinalizerToWeak ------------------------------------------------+-------------------------- Reporter: akio | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 7.6.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Incorrect result at runtime | (amd64) Test Case: | Difficulty: Blocking: | Unknown | Blocked By: | Related Tickets: ------------------------------------------------+-------------------------- Changes (by ezyang): * status: closed => new * resolution: fixed => Comment: Hate to be a wet sock but this test is failing in Windows. {{{ bash.exe-3.1$ gdb 'c:/Users/ezyang/Dev/ghc-dyn/inplace/bin/ghc-stage2.exe' -ex "run -fforce-re comp -dcore-lint -dcmm-lint -dno-debug-output -no-user-package-db -rtsopts -fno-ghci-history T 8242.hs --interactive -v0 -ignore-dot-ghci +RTS -I0.1 -DS -RTS" GNU gdb (GDB) 7.5 Copyright (C) 2012 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "i686-pc-mingw32". For bug reporting instructions, please see: http://www.gnu.org/software/gdb/bugs/... Reading symbols from c:\Users\ezyang\Dev\ghc-dyn\inplace\bin\ghc- stage2.exe...done. Starting program: c:\Users\ezyang\Dev\ghc-dyn\inplace\bin\ghc-stage2.exe -fforce-recomp -dcore- lint -dcmm-lint -dno-debug-output -no-user-package-db -rtsopts -fno-ghci- history T8242.hs --int eractive -v0 -ignore-dot-ghci +RTS -I0.1 -DS -RTS [New Thread 20508.0x52b0] 52b0: cap 0: initialised [New Thread 20508.0x52b4] [New Thread 20508.0x5078] [New Thread 20508.0x510c] [New Thread 20508.0x52f4] *Main> :set prog T8242 *Main> :set args *Main> GHC.TopHandler.runIOFastExit Main.main Prelude.>> Prelude.return () 510c: cap 1: initialised [New Thread 20508.0x201c] Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 20508.0x510c] 0x01d9d521 in LOOKS_LIKE_INFO_PTR_NOT_NULL (p=2863311360) at includes/rts/storage/ClosureMacros.h:248 248 return info->type != INVALID_OBJECT && info->type < N_CLOSURE_TYPES; (gdb) bt #0 0x01d9d521 in LOOKS_LIKE_INFO_PTR_NOT_NULL (p=2863311360) at includes/rts/storage/ClosureMacros.h:248 #1 0x01d9d564 in LOOKS_LIKE_INFO_PTR (p=2863311360) at includes/rts/storage/ClosureMacros.h:253 #2 0x01d9d591 in LOOKS_LIKE_CLOSURE_PTR (p=0x42ddc70) at includes/rts/storage/ClosureMacros.h:258 #3 0x01d9d65b in checkClosureShallow (p=0x42ddc70) at rts\sm\Sanity.c:87 #4 0x01d9d618 in checkLargeBitmap (payload=0x42d1e3c, large_bitmap=0x4176e24, size=1) at rts\sm\Sanity.c:69 #5 0x01d9d7c9 in checkStackFrame (c=0x42d1e34) at rts\sm\Sanity.c:129 #6 0x01d9d925 in checkStackChunk (sp=0x42d1e34, stack_end=0x42d1eb0) at rts\sm\Sanity.c:177 #7 0x01d9e394 in checkSTACK (stack=0x42d1af4) at rts\sm\Sanity.c:497 #8 0x01d9e4f3 in checkTSO (tso=0x42d1eb0) at rts\sm\Sanity.c:535 #9 0x01d861fb in scheduleHandleYield (cap=0x2a838e8, t=0x42d1eb0, prev_what_next=1) at rts\Schedule.c:1209 #10 0x01d85565 in schedule (initialCapability=0x2a838e8, task=0x24465b0) at rts\Schedule.c:533 #11 0x01d87483 in scheduleWorker (cap=0x2a838e8, task=0x24465b0) at rts\Schedule.c:2363 #12 0x01dab1c2 in workerStart (task=0x24465b0) at rts\Task.c:385 #13 0x74f8850d in UnregisterBadMemoryNotification () from C:\Windows\SysWOW64\kernel32.dll #14 0x024465b0 in ?? () #15 0x76ffbf39 in ?? () #16 0x76ffbf0c in ?? () #17 0x00000000 in ?? () (gdb) f 2 #2 0x01d9d591 in LOOKS_LIKE_CLOSURE_PTR (p=0x42ddc70) at includes/rts/storage/ClosureMacros.h:258 258 return LOOKS_LIKE_INFO_PTR((StgWord)(UNTAG_CLOSURE((StgClosure *)(p)))->header.info ); (gdb) p/x *(void**)p $1 = 0xaaaaaa00 }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8242#comment:11 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8242: Infinite loop with addCFinalizerToWeak ------------------------------------------------+-------------------------- Reporter: akio | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 7.6.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Incorrect result at runtime | (amd64) Test Case: T8242 | Difficulty: Blocking: | Unknown | Blocked By: | Related Tickets: ------------------------------------------------+-------------------------- Changes (by ezyang): * testcase: => T8242 -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8242#comment:12 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8242: Infinite loop with addCFinalizerToWeak ------------------------------------------------+-------------------------- Reporter: akio | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 7.6.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Incorrect result at runtime | (amd64) Test Case: T8242 | Difficulty: Blocking: | Unknown | Blocked By: | Related Tickets: ------------------------------------------------+-------------------------- Comment (by akio): It seems that the crash on Windows has nothing to do with weak pointers. I attached a test case that does not use weak pointers. It looks like GHCi doesn't correctly handle primops that return {{{(# State# RealWorld, Int# #)}}}. Should there be a separate ticket for this? -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8242#comment:13 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8242: Infinite loop with addCFinalizerToWeak ------------------------------------------------+-------------------------- Reporter: akio | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 7.6.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Incorrect result at runtime | (amd64) Test Case: T8242 | Difficulty: Blocking: | Unknown | Blocked By: | Related Tickets: ------------------------------------------------+-------------------------- Changes (by akio): * cc: simonmar (added) Comment: I believe #8377 is causing the test failure on Windows. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8242#comment:14 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8242: Infinite loop with addCFinalizerToWeak ------------------------------------------------+-------------------------- Reporter: akio | Owner: Type: bug | Status: patch Priority: normal | Milestone: Component: Runtime System | Version: 7.6.3 Resolution: | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Incorrect result at runtime | (amd64) Test Case: T8242 | Difficulty: Blocking: | Unknown | Blocked By: | Related Tickets: ------------------------------------------------+-------------------------- Changes (by akio): * status: new => patch Comment: The test now passes on Windows. Also I found a bug in the test case where a dangling pointer is dereferenced, so I attached a patch to fix it. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8242#comment:15 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#8242: Infinite loop with addCFinalizerToWeak ------------------------------------------------+-------------------------- Reporter: akio | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: Runtime System | Version: 7.6.3 Resolution: fixed | Keywords: Operating System: Linux | Architecture: x86_64 Type of failure: Incorrect result at runtime | (amd64) Test Case: T8242 | Difficulty: Blocking: | Unknown | Blocked By: | Related Tickets: ------------------------------------------------+-------------------------- Changes (by thoughtpolice): * status: patch => closed * resolution: => fixed Comment: Merged, thanks! -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/8242#comment:16 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC