Bug 22751 – DMD as a library crashes with fatal() on parseModule

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-02-08T23:38:34Z
Last change time
2022-02-17T23:46:10Z
Keywords
pull
Assigned to
No Owner
Creator
Luís Ferreira

Comments

Comment #0 by contact — 2022-02-08T23:38:34Z
If Module.parseModule() is used on a file with, e.g. invalid BOM sequence, the function instead of returning an invalidated AST node, it hangs the program with exit code 1.
Comment #1 by dlang-bot — 2022-02-08T23:40:33Z
@ljmf00 updated dlang/dmd pull request #13625 "frontend: propagate error as null instead of exit(1)" fixing this issue: - frontend: propagate error as null instead of exit(1) This patch propagates null when Module AST node can't be constructed correctly instead of doing fatal(), which terminates the program. This is useful if users use DMD frontend as a library. This patch also increases coverage on the affected lines. Fixes issue 22751. Signed-off-by: Luís Ferreira <[email protected]> https://github.com/dlang/dmd/pull/13625
Comment #2 by razvan.nitu1305 — 2022-02-14T12:12:29Z
Could please assist your bug reports with a reproducing example? It is hard to assess whether the bug report and/or the fix are valid without it.
Comment #3 by snarwin+bugzilla — 2022-02-17T17:16:14Z
dmdtags [1] is affected by this bug: --- $ printf 'module valid;' > valid.d $ printf '\xFF' > invalid.d $ dmdtags valid.d invalid.d $ echo $? 1 $ grep valid tags grep: tags: No such file or directory --- This is especially troublesome when using `dmdtags -R`, since a single invalid file anywhere in the directory tree causes tag generation to fail for *all* files. [1]: https://github.com/pbackus/dmdtags
Comment #4 by dlang-bot — 2022-02-17T23:46:10Z
dlang/dmd pull request #13625 "frontend: propagate error as null instead of exit(1)" was merged into master: - ffd3994fd3ee9c8cf7e78236fb4c224525000f34 by Luís Ferreira: frontend: propagate error as null instead of exit(1) This patch propagates null when Module AST node can't be constructed correctly instead of doing fatal(), which terminates the program. This is useful if users use DMD frontend as a library. This patch also increases coverage on the affected lines. Fixes issue 22751. Signed-off-by: Luís Ferreira <[email protected]> https://github.com/dlang/dmd/pull/13625