Bug 12130 – Segmentation fault if HOME environment variable does not exist

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2014-02-10T04:37:00Z
Last change time
2015-02-18T03:36:47Z
Keywords
ice, pull
Assigned to
nobody
Creator
maximzms

Attachments

IDFilenameSummaryContent-TypeSize
1423env.txtenv outputtext/plain4381
1424uname-all.txtuname outputtext/plain150
1425dmd-help.txtdmdtext/plain3490

Comments

Comment #0 by maximzms — 2014-02-10T04:37:09Z
-------------------- $ unset HOME $ dmd --help Segmentation fault --------------------
Comment #1 by hsteoh — 2014-09-11T18:40:21Z
Which version of dmd does this problem occur in? I can't seem to reproduce it in git HEAD.
Comment #2 by hsteoh — 2014-09-11T18:53:43Z
Can't reproduce this bug in 2.060, 2.064, 2.065, 2.066, and git HEAD. Tested on Linux/x86_64. Can you provide more info about your environment to help track this down? Thanks!
Comment #3 by maximzms — 2014-09-12T04:39:12Z
Created attachment 1423 env output $ env > env.txt
Comment #4 by maximzms — 2014-09-12T04:42:06Z
Created attachment 1424 uname output uname --all > uname-all.txt
Comment #5 by maximzms — 2014-09-12T04:44:29Z
Created attachment 1425 dmd $ dmd --help > dmd-help.txt
Comment #6 by hsteoh — 2014-09-12T18:05:14Z
Aha! The problem is caused by your PATH having a literal '~' character in it. This causes dmd to call getenv("PATH"), but it fails to check a NULL return value, so when HOME is unset, it calls strlen(NULL) which segfaults.
Comment #7 by hsteoh — 2014-09-12T18:13:48Z
Comment #8 by github-bugzilla — 2014-09-12T19:24:54Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/9b6ecade13236c97a70d1aa66afa13336379d6dc Merge pull request #3980 from quickfur/issue12130 Check for NULL when looking up getenv("HOME").
Comment #9 by github-bugzilla — 2015-02-18T03:36:47Z