Thread overview
[Issue 20235] C++ ABI doesn't destruct struct arguments in the callee
Sep 21, 2019
kinke
Nov 29, 2019
Dlang Bot
Oct 09, 2020
Walter Bright
Oct 09, 2020
Walter Bright
Dec 01, 2020
Dlang Bot
Jan 28, 2021
Dlang Bot
Jan 31, 2021
Dlang Bot
September 21, 2019
https://issues.dlang.org/show_bug.cgi?id=20235

kinke <kinke@gmx.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kinke@gmx.net

--- Comment #1 from kinke <kinke@gmx.net> ---
(In reply to Suleyman Sahmi (سليمان السهمي) from comment #0)
> This causes some double free bugs.

Double free/destruction if caller is in C++ and callee in D, no destruction at all the other way around.

--
September 22, 2019
https://issues.dlang.org/show_bug.cgi?id=20235

--- Comment #2 from Suleyman Sahmi (سليمان السهمي) <sahmi.soulaimane@gmail.com> ---
> Double free/destruction if caller is in C++ and callee in D, no destruction at all the other way around.
Yes.

--
November 29, 2019
https://issues.dlang.org/show_bug.cgi?id=20235

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

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

--- Comment #3 from Dlang Bot <dlang-bot@dlang.rocks> ---
@SSoulaimane updated dlang/dmd pull request #10593 "Fix issue 20235 - caller destroys arguments on POSIX" fixing this issue:

- Fix issue 20235 - caller destroys arguments on POSIX

  On Windows arguments are destroyed in the callee regardless of which calling
convention is used (cdecl, stdcall... etc), 32bits and 64bits alike.

  On the other platforms, the caller destroys the arguments if the caller
cleans the stack.

https://github.com/dlang/dmd/pull/10593

--
October 09, 2020
https://issues.dlang.org/show_bug.cgi?id=20235

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |wrong-code
                 CC|                            |bugzilla@digitalmars.com

--
October 09, 2020
https://issues.dlang.org/show_bug.cgi?id=20235

Walter Bright <bugzilla@digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |industry

--
December 01, 2020
https://issues.dlang.org/show_bug.cgi?id=20235

--- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> ---
@WalterBright created dlang/dmd pull request #12012 "Reboot of Fix issue 20235 - caller destroys arguments on POSIX #10593" fixing this issue:

- Fix issue 20235 - caller destroys arguments on POSIX

  On Windows arguments are destroyed in the callee regardless of which calling
convention is used (cdecl, stdcall... etc), 32bits and 64bits alike.

  On the other platforms, the caller destroys the arguments if the caller
cleans the stack.

https://github.com/dlang/dmd/pull/12012

--
January 28, 2021
https://issues.dlang.org/show_bug.cgi?id=20235

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 #12012 "Reboot of Fix issue 20235 - caller destroys arguments on POSIX #10593" was merged into master:

- 87206db1c37c22b5bfab5a46aa0cf56192a903c5 by سليمان السهمي (Suleyman Sahmi):
  Fix issue 20235 - Caller destroys arguments on POSIX

  On Windows, arguments are destroyed in the callee,
  regardless of which calling convention is used (cdecl, stdcall... etc),
  32bits and 64bits alike.

  On the other platforms, the caller destroys the arguments if the caller
cleans the stack.
  This changes the backend to respect the POSIX ABI on POSIX,
  allowing to correctly pass C++ objects by value accross language boundaries.

  Co-authored-by: Walter Bright <walter@walterbright.com>

https://github.com/dlang/dmd/pull/12012

--
January 31, 2021
https://issues.dlang.org/show_bug.cgi?id=20235

--- Comment #6 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #12162 "Issue 20235 - Simplify fix by not declaring __gate" was merged into master:

- 1c681d504f5b696c09d1755bb3630dc1790c61ff by Martin Kinkelin:
  Issue 20235 - Simplify fix by not declaring __gate

  Following Martin Kinkelin's comment in PR #12012:
  > We have the edtor `=> (__gate || edtor)` rewrite.
  > IIRC, the whole point of this `__gate` is to transfer ownership
  > of all temporary args requiring destruction to the callee just before the
call
  > (i.e., if all arguments were constructed successfully without throw).
  > For `extern(D)`, it's up to the callee to destruct the parameter
  > [which, low-level wise, is either the original argument passed by ref or a
moved/blitted instance].
  >
  > So if `callerDestroysArgs == true`, it should suffice to keep the original
`edtor`
  > and not declaring+setting `__gate`.

  Source: https://github.com/dlang/dmd/pull/12012#event-4259809188

https://github.com/dlang/dmd/pull/12162

--