8000 Fix bug in call_memory tracing when calling BIFs that delay GC by sverker · Pull Request #9706 · erlang/otp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix bug in call_memory tracing when calling BIFs that delay GC #9706

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

sverker
Copy link
Contributor
@sverker sverker commented Apr 8, 2025

Tracing functions with call_memory could report arbitrarily incorrect values for consumed memory. Even negative values. This could happen if the traced process called BIFs that yielded while delaying garbage collection, like binary_to_list/1.

@sverker sverker added team:VM Assigned to OTP team VM fix labels Apr 8, 2025
@sverker sverker self-assigned this Apr 8, 2025
garazdawi
garazdawi previously approved these changes Apr 9, 2025
@frazze-jobb frazze-jobb requested a review from Copilot April 9, 2025 10:28
Copy link
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.

Files not reviewed (1)
  • lib/kernel/src/trace.erl: Language not supported
Comments suppressed due to low confidence (1)

erts/emulator/beam/erl_gc.c:578

  • Ensure that updating p->high_water at this new location handles all code paths, including cases where p->abandoned_heap is true, so that the memory break adjustment is consistently applied.
p->high_water = p->heap;

Copy link
Contributor
github-actions bot commented Apr 9, 2025

CT Test Results

    4 files    200 suites   1h 59m 29s ⏱️
3 079 tests 2 773 ✅ 302 💤 4 ❌
4 057 runs  3 671 ✅ 381 💤 5 ❌

For more details on these failures, see this check.

Results for commit 576b6e2.

♻️ This comment has been updated with latest results.

To speed up review, make sure that you have read Contributing to Erlang/OTP and that all checks pass.

See the TESTING and DEVELOPMENT HowTo guides for details about how to run test locally.

Artifacts

// Erlang/OTP Github Action Bot

@sverker sverker force-pushed the sverker/erts/call_memory-delay-gc-bug/OTP-19581 branch from 06c737f to 427b111 Compare April 9, 2025 17:54
@sverker sverker requested a review from bjorng April 9, 2025 17:54
sverker added 2 commits April 10, 2025 12:32
The call to erts_adjust_memory_break(, orig_htop - p->high_water)
must use the old value of p->high_water.

Otherwise the reported call_memory value may get arbitrarily wrong,
even negative number of words.
@sverker sverker force-pushed the sverker/erts/call_memory-delay-gc-bug/OTP-19581 branch from 427b111 to 576b6e2 Compare April 10, 2025 10:33
@sverker sverker removed the request for review from bjorng April 10, 2025 10:55
@sverker sverker merged commit e7fbb37 into erlang:master Apr 11, 2025
24 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix team:VM Assigned to OTP team VM
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0