Ticket #7037 (closed bug: fixed)
setProgName() crashes when argv[0] == NULL
| Reported by: | shachaf | Owned by: | simonmar |
|---|---|---|---|
| Priority: | high | Milestone: | 7.6.1 |
| Component: | Runtime System | Version: | 7.4.2 |
| Keywords: | Cc: | ||
| Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
| Type of failure: | Runtime crash | Difficulty: | Unknown |
| Test Case: | rts/T7037 | Blocked By: | |
| Blocking: | Related Tickets: |
Description
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);.
Change History
Note: See
TracTickets for help on using
tickets.
