Bug 23874 – -profile=gc segfaults / ICE regression

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2023-05-02T00:21:50Z
Last change time
2023-05-16T12:28:57Z
Keywords
pull
Assigned to
No Owner
Creator
Jan Jurzitza

Comments

Comment #0 by d.bugs — 2023-05-02T00:21:50Z
reproduction: reduced.d ``` static if (is(typeof(new Object()))) void foo() { } ``` dmd -c -profile=gc reduced.d currently breaks building msgpack-d / DCD with profile-gc, which is needed for CI / measuring memory usage in a PR. Regressed with DMD 2.103.0
Comment #1 by d.bugs — 2023-05-02T00:35:01Z
note: the code to reproduce has been fixed with https://github.com/dlang/dmd/commit/abb7836dd705be4f3c82e606b31d54dd69276476 on master, but that did not seem intentional and I'm keeping this open until the real regression cause has been identified and can be confirmed fixed by this. Regression was introduced by https://github.com/dlang/dmd/commit/276ef2145b2cab876c82845d2d1e943847ea2f3a
Comment #2 by d.bugs — 2023-05-02T01:14:04Z
alternative reproduction that works with master: reduced2.d ``` string myToString() { } enum x = myToString ~ ""; ``` dmd -c -profile=gc reduced2.d this one regressed in https://github.com/dlang/dmd/commit/1db1ba87fd23d45f1bffaea07efe7dc8070ffef1 different commit, but the issue is also introduced by template translation here. So it looks like there is some issue further up blocks the same msgpack-d / DCD project
Comment #3 by razvan.nitu1305 — 2023-05-02T09:23:37Z
(In reply to Jan Jurzitza from comment #1) > note: the code to reproduce has been fixed with > https://github.com/dlang/dmd/commit/abb7836dd705be4f3c82e606b31d54dd69276476 > on master, but that did not seem intentional and I'm keeping this open until > the real regression cause has been identified and can be confirmed fixed by > this. > > Regression was introduced by > https://github.com/dlang/dmd/commit/276ef2145b2cab876c82845d2d1e943847ea2f3a Actually, even though the fix was not intentional it is the proper fix. The underlying issue stems from the fact that the profile gc hook needs to be given a function name so that it outputs where the allocation takes place (allocations that are not inside function bodies are compile time allocations therefore do not require the gc). However, in speculative contexts (such as the ones provided in this bug report) you are not necessarily inside a function body, therefore when the hook is instantiated it tries to pass a function name (taken from a null object). That is why the fix linked here correctly solves this issue by avoiding to lower to the druntime hook if no code is going to be generated. There probably might be other slips of this sort so please file them as individual bugs (not as comments to this bug report) if you discover them. I am going to fix the case that is provided in this bug report so please do not link any other manifestations.
Comment #4 by dlang-bot — 2023-05-02T09:57:30Z
@RazvanN7 created dlang/dmd pull request #15164 "Fix Issue 23874 - -profile=gc segfaults / ICE regression" fixing this issue: - Fix Issue 23874 - -profile=gc segfaults / ICE regression https://github.com/dlang/dmd/pull/15164
Comment #5 by dlang-bot — 2023-05-02T12:28:04Z
dlang/dmd pull request #15164 "Fix Issue 23874 - -profile=gc segfaults / ICE regression" was merged into stable: - 5e7383817f4951f0553cb9e2638c2ecae0a41f1c by RazvanN7: Fix Issue 23874 - -profile=gc segfaults / ICE regression https://github.com/dlang/dmd/pull/15164
Comment #6 by d.bugs — 2023-05-02T13:59:07Z
the fix didn't fully resolve this ICE, this still segfaults: reduced.d ``` string myToString() { return ""; } immutable x = myToString ~ ""; ```
Comment #7 by dlang-bot — 2023-05-03T07:12:46Z
@rainers updated dlang/dmd pull request #15170 "fix issues 20737 and 23024 - TLS variables unusable with -betterC/imp…" fixing this issue: - Fix Issue 23874 - -profile=gc segfaults / ICE regression https://github.com/dlang/dmd/pull/15170
Comment #8 by dlang-bot — 2023-05-04T14:27:45Z
@RazvanN7 created dlang/dmd pull request #15179 "Fix Issue 23874 - -profile=gc segfaults / ICE regression - part 2" fixing this issue: - Fix Issue 23874 - -profile=gc segfaults / ICE regression https://github.com/dlang/dmd/pull/15179
Comment #9 by dlang-bot — 2023-05-05T07:19:43Z
dlang/dmd pull request #15179 "Fix Issue 23874 - -profile=gc segfaults / ICE regression - part 2" was merged into stable: - a2db946b3bb157da3df68858bf11d75a71089b56 by RazvanN7: Fix Issue 23874 - -profile=gc segfaults / ICE regression https://github.com/dlang/dmd/pull/15179
Comment #10 by dlang-bot — 2023-05-16T12:28:57Z
dlang/dmd pull request #15238 "merge stable" was merged into master: - 6d0a9a5607b945dc45cfb22a0d6be16e063cece8 by RazvanN7: Fix Issue 23874 - -profile=gc segfaults / ICE regression - f467b2607400c0ff015be4d9da121baa7ef9adab by Razvan Nitu: Fix Issue 23874 - -profile=gc segfaults / ICE regression (#15179) https://github.com/dlang/dmd/pull/15238