Skip to content

fix(ext/signals): prevent panic on FreeBSD#32518

Merged
bartlomieju merged 2 commits intodenoland:mainfrom
amyssnippet:fix/31087
Mar 11, 2026
Merged

fix(ext/signals): prevent panic on FreeBSD#32518
bartlomieju merged 2 commits intodenoland:mainfrom
amyssnippet:fix/31087

Conversation

@amyssnippet
Copy link
Contributor

This PR fixes a panic in Deno on FreeBSD when running tasks (e.g., deno task georg). The issue occurs because the signal dictionary for FreeBSD incorrectly includes SIGLIBRT (signal 33), which is not defined on FreeBSD, leading to an EINVAL error when attempting to bind or handle signals.

Changes

  1. Removed (33, "SIGLIBRT") from the FreeBSD signal dictionary (ext/signals/dict.rs) — SIGLIBRT is a non-catchable internal threading signal, similar to SIGKILL/SIGSTOP. It should not be in the dictionary of handleable signals.

  2. Replaced .unwrap() with error propagation on add_signal (ext/signals/lib.rs) — The bare .unwrap() on a syscall that can legitimately fail is a bug regardless of the dictionary fix. All existing callers already handle errors gracefully:

    • listen_and_forward_all_signals uses let Ok(...) else { return } to skip unsupported signals
    • op_signal_bind propagates errors to JavaScript via ?

Related Issue
fixes #31087

@amyssnippet amyssnippet changed the title prevent panic on FreeBSD by removing SIGLIBRT and handling add_signal errors fix(ext/signals):prevent panic on FreeBSD by removing SIGLIBRT and handling add_signal errors Mar 6, 2026
@amyssnippet
Copy link
Contributor Author

@dsherret and @bartlomieju ,

actually this is a new pr regarding the closed #31096 , which was unrelated, at that time i was not able to make the changes and solve the issue, i was unaware of the codebase of deno cli, sorry for that, but rn i figured out a way to solve the issue and here is the proposed changes. kindly review this ones

Copy link
Contributor

@kajukitli kajukitli left a comment

Choose a reason for hiding this comment

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

lgtm, two small things:

  1. SIGTHR also removed? — the diff shows you removed both SIGTHR (32) and SIGLIBRT (33), but the commit message only mentions SIGLIBRT. was SIGTHR intentionally kept? looking at the diff it seems like SIGTHR is still there (line ends with (32, "SIGTHR")), just the trailing comma situation changed. nvm, i misread — you're good.

  2. error message format — nitpick: std::io::Error::other(format!(...)) works but you could also just do std::io::Error::new(std::io::ErrorKind::Other, format!(...)) for slightly more idiomatic code. either way is fine.

the fix itself is correct — SIGLIBRT is indeed non-catchable on FreeBSD (similar to SIGKILL/SIGSTOP) and shouldn't be in the handleable signals dict. and replacing .unwrap() with proper error propagation is the right call.

@bartlomieju
Copy link
Member

Please answer the above questions ^^

@amyssnippet
Copy link
Contributor Author

lgtm, two small things:

  1. SIGTHR also removed? — the diff shows you removed both SIGTHR (32) and SIGLIBRT (33), but the commit message only mentions SIGLIBRT. was SIGTHR intentionally kept? looking at the diff it seems like SIGTHR is still there (line ends with (32, "SIGTHR")), just the trailing comma situation changed. nvm, i misread — you're good.

The diff looks confusing because of the trailing comma change.

  1. error message format — nitpick: std::io::Error::other(format!(...)) works but you could also just do std::io::Error::new(std::io::ErrorKind::Other, format!(...)) for slightly more idiomatic code. either way is fine.

Keeping std::io::Error::other(...) since that's the pattern used throughout ext (18+ usages, 0 for the longer form). It's the modern Rust shorthand.

@amyssnippet
Copy link
Contributor Author

@bartlomieju ??

@amyssnippet amyssnippet requested a review from kajukitli March 8, 2026 14:10
@halcyon
Copy link

halcyon commented Mar 11, 2026

@kajukitli @bartlomieju FreeBSD users await your review/feedback. Thank you @amyssnippet

@bartlomieju bartlomieju changed the title fix(ext/signals):prevent panic on FreeBSD by removing SIGLIBRT and handling add_signal errors fix(ext/signals): prevent panic on FreeBSD Mar 11, 2026
@bartlomieju bartlomieju enabled auto-merge (squash) March 11, 2026 21:37
@bartlomieju bartlomieju disabled auto-merge March 11, 2026 21:37
@bartlomieju bartlomieju merged commit 7c84b09 into denoland:main Mar 11, 2026
112 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"deno task" panics on freebsd

4 participants