runtime_tools: fix dbg:session/2 cleanup when calling process exits#11260
Open
madlep wants to merge 3 commits into
Open
runtime_tools: fix dbg:session/2 cleanup when calling process exits#11260madlep wants to merge 3 commits into
madlep wants to merge 3 commits into
Conversation
If process that called `dbg:session/2` exits before
`dbg:session_destroy/1 is called, an error is encountered and an error
report logged, and any trace messages are lost and not delivered.
The existing logic seemed to be treating the `Session` stored in the
process dictionary as a `dbg:session()` type (ie a pid), and passing it
to `dbg:session_destroy/1`, however, it is actually a `trace` session,
and can't be used directly as a pid in `dbg:session_destroy/1`
Instead, fix this by extracting logic from `stop` message handler clause
to clean up and ensure messages are delivered in the same way.
This issue can be reproduced with the following code:
```erlang
1> spawn_link(fun() ->
DbgSession = dbg:session_create(my_session),
dbg:session(DbgSession, fun() ->
dbg:tracer()
end)
end).
<0.102.0>
=ERROR REPORT==== 17-Jun-2026::22:04:51.331934 ===
Error in process <0.103.0> with exit value:
{badarg,[{erlang,monitor,
[process,{#Ref<0.3577390006.3558211590.1705>,{my_session,0}}],
[{error_info,#{module => erl_erts_errors}}]},
{dbg,session_destroy,1,[{file,"dbg.erl"},{line,1741}]},
{dbg,loop,4,[{file,"dbg.erl"},{line,1948}]}]}
```
If the generated release directory name is very long, it can exceed the 255 character atom name limit, and result in test failures to due exceeding system limits. Truncate the atom name to 255 chars - which matches what the code under test does anyway.
Contributor
CT Test Results 2 files 20 suites 4m 17s ⏱️ Results for commit 40cebba. ♻️ 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If process that called
dbg:session/2exits beforedbg:session_destroy/1is called, an error is encountered and an error report logged, and any trace messages are lost and not delivered.The existing logic seemed to be treating the
Sessionstored in the process dictionary as adbg:session()type (ie a pid), and passing it todbg:session_destroy/1, however, it is actually atracesession, and can't be used directly as a pid indbg:session_destroy/1Instead, fix this by extracting logic from
stopmessage handler clause to clean up and ensure messages are delivered in the same way.This issue can be reproduced with the following code:
catchusage in test modulelist_to_atom/1due to long release path name on local laptop.