Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jcpetruzza
Copy link
Contributor

Context

erlang:suspend_process() was broken when applied on processes that happened to be in a dirty-scheduler. The symptom was:

  • internal_error would be returned when called synchronously
  • not_suspended would be delivered when called asynchronously, even though the process was in fact suspended

Problem

When trying to suspend a processes in a dirty-scheduler, it is actually the dirty-scheduler who suspends the process, by calling erts_proc_sig_handle_pending_suspend(). This essentially activates all pending suspend monitors and finally sends all pending sync messages, by calling sync_suspend_reply().

The problem is that when calling the latter, it is passing the process state before activating the monitors. In particular, the SUSPENDED flag is not set, what makes sync_suspend_reply() assume that something is wrong.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 24, 2025

CT Test Results

    3 files    142 suites   50m 22s ⏱️
1 650 tests 1 593 ✅ 57 💤 0 ❌
2 373 runs  2 296 ✅ 77 💤 0 ❌

Results for commit 410680d.

♻️ 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

@IngelaAndin IngelaAndin added the team:VM Assigned to OTP team VM label Sep 26, 2025
@rickard-green rickard-green added the testing currently being tested, tag is used by OTP internal CI label Sep 27, 2025
# Context
`erlang:suspend_process()` was broken when applied on processes that
happened to be in a dirty-scheduler. The symptom was:
  - `internal_error` would be returned when called synchronously
  - `not_suspended` would be delivered when called asynchronously,
     even though the process was in fact suspended

# Problem
When trying to suspend a processes in a dirty-scheduler, it is actually
the dirty-scheduler who suspends the process, by calling
`erts_proc_sig_handle_pending_suspend()`. This essentially activates all
pending suspend monitors and finally sends all pending sync messages, by
calling `sync_suspend_reply()`.

The problem is that when calling the latter, it is passing the process
state *before* activating the monitors. In particular, the SUSPENDED
flag is not set, what makes `sync_suspend_reply()` assume that something
is wrong.
@rickard-green rickard-green force-pushed the fix_suspend_internal_error branch from b91bf2b to c7897c6 Compare October 1, 2025 11:43
@rickard-green rickard-green changed the base branch from master to maint October 1, 2025 11:44
@rickard-green
Copy link
Contributor

rickard-green commented Oct 1, 2025

Thanks! I've rebased the fix onto OTP 26.2.5 (so we can patch this) and added a test case and force pushed the fix.

@rickard-green rickard-green removed the testing currently being tested, tag is used by OTP internal CI label Oct 2, 2025
@rickard-green rickard-green force-pushed the fix_suspend_internal_error branch from c7897c6 to 410680d Compare October 2, 2025 14:57
@rickard-green rickard-green merged commit f8c9118 into erlang:maint Oct 3, 2025
26 of 27 checks passed
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants