Thread overview
[Issue 23874] -profile=gc segfaults / ICE regression
May 02, 2023
Jan Jurzitza
May 02, 2023
Jan Jurzitza
May 02, 2023
RazvanN
May 02, 2023
Dlang Bot
May 02, 2023
Dlang Bot
May 02, 2023
Jan Jurzitza
May 03, 2023
Dlang Bot
May 04, 2023
Dlang Bot
May 05, 2023
Dlang Bot
May 16, 2023
Dlang Bot
May 02, 2023
https://issues.dlang.org/show_bug.cgi?id=23874

--- Comment #1 from Jan Jurzitza <d.bugs@webfreak.org> ---
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

--
May 02, 2023
https://issues.dlang.org/show_bug.cgi?id=23874

--- Comment #2 from Jan Jurzitza <d.bugs@webfreak.org> ---
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

--
May 02, 2023
https://issues.dlang.org/show_bug.cgi?id=23874

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |razvan.nitu1305@gmail.com

--- Comment #3 from RazvanN <razvan.nitu1305@gmail.com> ---
(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.

--
May 02, 2023
https://issues.dlang.org/show_bug.cgi?id=23874

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> ---
@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

--
May 02, 2023
https://issues.dlang.org/show_bug.cgi?id=23874

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #5 from Dlang Bot <dlang-bot@dlang.rocks> ---
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

--
May 02, 2023
https://issues.dlang.org/show_bug.cgi?id=23874

Jan Jurzitza <d.bugs@webfreak.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |---

--- Comment #6 from Jan Jurzitza <d.bugs@webfreak.org> ---
the fix didn't fully resolve this ICE, this still segfaults:

reduced.d
```
string myToString()
{
    return "";
}

immutable x = myToString ~ "";
```

--
May 03, 2023
https://issues.dlang.org/show_bug.cgi?id=23874

--- Comment #7 from Dlang Bot <dlang-bot@dlang.rocks> ---
@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

--
May 04, 2023
https://issues.dlang.org/show_bug.cgi?id=23874

--- Comment #8 from Dlang Bot <dlang-bot@dlang.rocks> ---
@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

--
May 05, 2023
https://issues.dlang.org/show_bug.cgi?id=23874

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|---                         |FIXED

--- Comment #9 from Dlang Bot <dlang-bot@dlang.rocks> ---
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

--
May 16, 2023
https://issues.dlang.org/show_bug.cgi?id=23874

--- Comment #10 from Dlang Bot <dlang-bot@dlang.rocks> ---
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

--