Bug 23438 – leaking address of stack using dip1000 switch

Status
REOPENED
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-10-26T18:40:20Z
Last change time
2024-12-13T19:25:13Z
Keywords
pull, safe
Assigned to
No Owner
Creator
Walter Bright
See also
https://issues.dlang.org/show_bug.cgi?id=22977, https://issues.dlang.org/show_bug.cgi?id=23445
Moved to GitHub: dmd#20170 →

Comments

Comment #0 by bugzilla — 2022-10-26T18:40:20Z
As reported by Timon Gehr: int global; int* escaped; void qux()@safe{ int stack=1337; int* foo(return scope int* x)@safe{ int* bar(return scope int* y)@safe{ return x; } escaped=bar(&global); return x; } foo(&stack); } void main()@safe{ qux(); import std.stdio; version(THRASH_STACK) writeln("thrashing stack"); writeln(*escaped); }
Comment #1 by dkorpel — 2022-10-27T13:00:52Z
*** This issue has been marked as a duplicate of issue 22977 ***
Comment #2 by bugzilla — 2022-10-29T05:11:21Z
(In reply to Dennis from comment #1) > > *** This issue has been marked as a duplicate of issue 22977 *** I thought it was a duplicate, too, but the PR for that does not detect the error.
Comment #3 by bugzilla — 2022-10-29T05:12:08Z
(In reply to Walter Bright from comment #2) > I thought it was a duplicate, too, but the PR for that does not detect the > error. The PR is: https://github.com/dlang/dmd/pull/14236
Comment #4 by bugzilla — 2022-10-29T05:13:27Z
A smaller test case: void qux()@safe{ int* foo(return scope int* x)@safe{ int* bar(return scope int* y)@safe{ return x; (*) } return null; } } (*) compiler should complain that x is escaping via return
Comment #5 by dlang-bot — 2022-10-29T05:34:56Z
@WalterBright created dlang/dmd pull request #14601 "Fix23438" fixing this issue: - fix Issue 23438 - leaking address of stack https://github.com/dlang/dmd/pull/14601
Comment #6 by dlang-bot — 2022-11-02T06:30:43Z
@WalterBright created dlang/dmd pull request #14610 "fix Issue 23445 - Can leak scope variable through delegate context" fixing this issue: - fix Issue 23438 - leaking address of stack https://github.com/dlang/dmd/pull/14610
Comment #7 by robert.schadek — 2024-12-13T19:25:13Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20170 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB