Skip to content

setProgName() crashes when argv[0] == NULL

C89 allows argc to be 0, in which case argv[0] is NULL. This can happen in practice in Linux+glibc with execve(program, {NULL}, ...);.

The RTS assumes that argv[0] always points to a valid string: void setProgName(char *argv[]) { char *last_slash; if ( (last_slash = (char *) strrchr(argv[0], '/')) != NULL ) { ... } else { ... } }.

This means that any GHC-compiled program can be made to segfault with execl("./ghc-compiled-program", NULL);.

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