#15250 closed bug (fixed)
jam crashes when given empty input file
Reported by: | simonsouth | Owned by: | bonefish |
---|---|---|---|
Priority: | normal | Milestone: | R1/beta2 |
Component: | Build System | Version: | R1/Development |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Platform: | All |
Description
jam will crash with a segmentation fault if given an empty input file to parse. This can happen if a user deletes every line from his UserBuildConfig, for instance, without deleting the file itself.
To demonstrate on Haiku, from within a "generated" subfolder beneath the Haiku source tree:
mv ../build/jam/UserBuildConfig{,.orig} touch ../build/jam/UserBuildConfig jam -q # This will segfault mv ../build/jam/UserBuildConfig{.orig,}
This happens because as part of its file-caching mechanism, jam will allocate but not initialize an array of string pointers to hold lines read from the file. If no lines are read (because the file is empty) the first element of the array is never replaced with a valid pointer, causing a segfault later when the program tries to parse the file's contents.
Changing jam so it initializes the first element of the array to zero solves the problem.
I'll upload a patch for review.
Change History (3)
comment:1 by , 5 years ago
comment:3 by , 5 years ago
Milestone: | Unscheduled → R1/beta2 |
---|
Assign tickets with status=closed and resolution=fixed within the R1/beta2 development window to the R1/beta2 Milestone
I've uploaded the patch here for review: https://review.haiku-os.org/c/buildtools/+/1716