dmd icon indicating copy to clipboard operation
dmd copied to clipboard

Fix issue 21893 - Fix `std.atomic.atomicStore` infinitely and recursively calling itself

Open avaxar opened this issue 1 year ago • 4 comments

Implements the change proposal in bug #21893, where std.atomic.atomicStore would infinitely and recursively call itself out of a vaguely-referenced function [which the compiler interpreted as calling itself].

avaxar avatar Jan 01 '24 12:01 avaxar

Thanks for your pull request and interest in making D better, @avaxar! We are looking forward to reviewing it, and you should be hearing from a maintainer soon. Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

⚠️⚠️⚠️ Warnings ⚠️⚠️⚠️

  • In preparation for migrating from Bugzilla to GitHub Issues, the issue reference syntax has changed. Please add the word "Bugzilla" to issue references. For example, Fix Bugzilla Issue 12345 or Fix Bugzilla 12345.(Reminder: the edit needs to be done in the Git commit message, not the GitHub pull request.)

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "stable + dmd#15973"

dlang-bot avatar Jan 01 '24 12:01 dlang-bot

Can you add a test for this?

dkorpel avatar Jan 01 '24 12:01 dkorpel

Briefly reading up the issue, I think you're missing some more places where this recursion could occur?

ibuclaw avatar Jan 01 '24 18:01 ibuclaw

_D4core6atomic__T11atomicStoreVEQBeQBc11MemoryOrderi5TiTiZQBpFNaNbNiNeKiiZv:
                push    RBP
                mov     RBP,RSP
                sub     RSP,020h
                mov     -010h[RBP],EDI
                mov     -8[RBP],RSI
                mov     EAX,-010h[RBP]
                mov     -018h[RBP],EAX
                mov     RSI,-8[RBP]
                mov     EDI,EAX
                call      _D4core8internal6atomic__T11atomicStoreVEQBnQBc11MemoryOrderi5TiZQBnFNaNbNiNePiiZv@PLT32
                leave

is it even true?

maxhaton avatar Jan 03 '24 18:01 maxhaton

The issue might be better off being fixed from LDC's side, as the issue is LDC-specific. It may have to do with LDC dereferencing the function overload calls inconsistently with DMD and GDC. So, I've forwarded the issue to ldc-developers/ldc#4701 instead.

avaxar avatar Jul 12 '24 11:07 avaxar