Skip to content
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

erl_gc: fix dynamic tracepoint for heap_grow #2932

Merged
merged 1 commit into from
Dec 22, 2020

Conversation

max-au
Copy link
Contributor

@max-au max-au commented Dec 15, 2020

If stack top is changed before calling heap_grow tracepoint,
the stack is not walk-able, because stack bottom points to
old heap, while stack top is already reset to new heap.

@IngelaAndin IngelaAndin added the team:VM Assigned to OTP team VM label Dec 16, 2020
@garazdawi
Copy link
Contributor

Wouldn't it make more sense to let the probe trigger after all the pointers have been updated to the new heap? That way the heap is also valid to traverse if one wants to.

Since we cannot write a testcase for this (I assume?), please add a comment in the code about why that line has to be after/before the dtrace probe.

@max-au
Copy link
Contributor Author

max-au commented Dec 17, 2020

If I understand correctly, old and new heaps are expected to be identical.

I can change it either way (e.g. move DTRACE invocation after HEAP_END(p) = n_heap + new_sz; or move it before /* Copy stack to end of new heap */, or add a comment). What would be the preferred solution?

@garazdawi
Copy link
Contributor

If I understand correctly, old and new heaps are expected to be identical.

Yes, but by the time the GC is done the previous heap will have been destroyed by GC forward pointers so it cannot be read, while the new heap will be intact.

I can change it either way (e.g. move DTRACE invocation after HEAP_END(p) = n_heap + new_sz; or move it before /* Copy stack to end of new heap */, or add a comment). What would be the preferred solution?

I think it would be best to move the DTRACE call until after all of the heap pointers have been updated.

@max-au max-au force-pushed the max-au/fix-tracepoint-invocation branch from 4d3cdd9 to 9d878be Compare December 18, 2020 07:15
erts/emulator/beam/erl_gc.c Show resolved Hide resolved
erts/emulator/beam/erl_gc.c Show resolved Hide resolved
If stack top is changed before calling heap_grow tracepoint,
the stack is not walk-able, because stack bottom points to
old heap, while stack top is already reset to new heap.
Move tracepoint after all heap references have been updated.
Fix warning when compiling with dtrace enabled.
@max-au max-au force-pushed the max-au/fix-tracepoint-invocation branch from 9d878be to 562cd99 Compare December 18, 2020 20:16
@garazdawi garazdawi added the testing currently being tested, tag is used by OTP internal CI label Dec 21, 2020
@garazdawi garazdawi self-assigned this Dec 21, 2020
@garazdawi garazdawi merged commit 949a90d into erlang:maint Dec 22, 2020
@max-au max-au deleted the max-au/fix-tracepoint-invocation branch June 30, 2021 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team:VM Assigned to OTP team VM testing currently being tested, tag is used by OTP internal CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants