Skip to content

Various dap fixes#1473

Open
nikitalita wants to merge 10 commits into
UZDoom:trunkfrom
nikitalita:various-dap-fixes
Open

Various dap fixes#1473
nikitalita wants to merge 10 commits into
UZDoom:trunkfrom
nikitalita:various-dap-fixes

Conversation

@nikitalita

Copy link
Copy Markdown
Contributor

Checklist

@github-actions

Copy link
Copy Markdown

Thanks for opening this PR! We'll review it soon.

I'm a bot that checks for some common problems. I'll update this comment with anything I find.

Nothing to report. Nice :)

@nikitalita nikitalita mentioned this pull request Jun 14, 2026
1 task
@RicardoLuis0 RicardoLuis0 requested a review from Gutawer June 14, 2026 19:44
Comment on lines +37 to +42
int64_t id = ++m_CurrentID;
if (id < 1)
{
m_CurrentID = 1;
id = m_CurrentID;
// if it hasn't already been replaced, replace it with 1
std::atomic_compare_exchange_strong(&m_CurrentID, &id, 1);
id = ++m_CurrentID;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the only way this could happen is if the int64 overflowed, right?

in which case, this seems a bit weird to me, e.g.:

  • say m_CurrentID == int64 max
  • thread A: int64_t id = ++m_CurrentID; // m_CurrentID == A.id == int64 min
  • thread A: if id < 1 (true)
  • thread B: int64_t id = ++m_CurrentID; // m_CurrentID == B.id = int64 min + 1
  • thread A: std::atomic_compare_exchange_strong(&m_CurrentID, &id, 1); // doesn't happen because A.id != m_CurrentID thanks to thread B
  • thread A: id = ++m_CurrentID; // A.id = int64 min + 2
  • then a negative number gets returned

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what do you suggest instead?

@Gutawer Gutawer Jun 16, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With the ID being a 64-bit int I'd honestly just suggest incrementing it and returning it, keeping it atomic ofc. With 32-bit I could see the reason for the bookkeeping here but on a 64-bit integer you could be generating one breakpoint ID per nanosecond and still only ever wraparound after hundreds of years

But the other alternative is a "CAS loop" where each thread keeps attempting to swap in its intended next value until it actually works, which can use the swap-into-expected-parameter behavior of the CAS functions for a marginal speed improvement

@RicardoLuis0 RicardoLuis0 added this to the 5.0 milestone Jun 20, 2026
@github-project-automation github-project-automation Bot moved this to Backlog in Road to 5.0 Jun 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

3 participants