Skip to content

Segfault in RTS (apparently only MacOS) FFI related?

The RTS crashes in the middle of a long-running computation involving multiple FFI calls. I suspect this has something to do with the foreign call spawning multiple threads, but I'm not sure.

Specifically, the crash is in the middle of a long loop. Each iteration performs a lot of memory allocation, so GC collections happen fairly frequently. Also, each iteration involves calls to the (external) BLAS function DGER. On my machine (dual-processor Mac OS with vecLib), BLAS functions are often multi-threaded. When I comment out the call to DGER, the bug does not manifest.

Here is the site of the crash (as reported by gdb):

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0xc000162d
0x003154ce in StgReturn () at rts/StgCRun.c:137
137	    __asm__ volatile (

Sometimes the crash is at:

rtsbug: internal error: ASSERTION FAILED: file rts/Schedule.c, line 536

I'm attaching source files for the buggy program. Unfortunately, they require BLAS and LAPACK. If there's anything I can do to help, I would be glad to assist.

Trac metadata
Trac field Value
Version 6.12.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Runtime System
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
Edited by Simon Peyton Jones
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information