Skip to content

Add disable_signals feature for debugging #300

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

Open
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

rennergade
Copy link
Contributor

This PR adds a compile feature to disable the signal epoch checks for debugging programs without signals. This helps for debugging and performance comparisons.

@Yaxuan-w
Copy link
Member

There're signal implementation in lind-multi-process crate: 1, 2.

We also need to deal with code calling lind_thread_exit: in run.rs, in Lind-multi-process1, 2.

Those are implementations I've identified related to signal stuffs now.

@rennergade
Copy link
Contributor Author

There're signal implementation in lind-multi-process crate: 1, 2.

We also need to deal with code calling lind_thread_exit: in run.rs, in Lind-multi-process1, 2.

Those are implementations I've identified related to signal stuffs now.

Okay thanks. I hadn't really thought about making this robust for multi-processing but it makes sense that we would want that for the things you're working on. I'll update and test this to include that.

@rennergade
Copy link
Contributor Author

There're signal implementation in lind-multi-process crate: 1, 2.

We also need to deal with code calling lind_thread_exit: in run.rs, in Lind-multi-process1, 2.

Those are implementations I've identified related to signal stuffs now.

I'm unsure what needs to be done for the lind_thread_exit parts. I think we only need to disable where it sets the underlying epoch?

I've fixed the other pieces but I'm trying to figure out how to pass down a feature during compilation into a subcrate to test. If anyone has experience with that let me know!

@rennergade
Copy link
Contributor Author

@Yaxuan-w I've confirmed this now works for multi-process programs with asyncify (but no epoch insertion) and now can compile conditionally with subcrate passthrough. Can you check this out again? Thanks!

@Yaxuan-w
Copy link
Member

If we don't disable lind_thread_exists, it will panic when exiting in multi-process scenario.

If we don't disable signal in multi-process part, it will also panic:

I tested with tests/unit-tests/process_tests/deterministic/thread.c and got following error:

lind@0fe82b11ea86:~/lind-wasm$ src/wasmtime/target/debug/wasmtime run --allow-precompiled --wasi threads=y --wasi preview2=n  tests/unit-tests/process_tests/deterministic/thread.cwasm
Hello from thread

thread 'main' panicked at crates/rawposix/src/interface/signal.rs:66:14:
null pointer dereference occurred
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread caused non-unwinding panic. aborting.
Aborted (core dumped)

Also tests/unit-tests/process_tests/deterministic/forkdup.c will fail:

lind@0fe82b11ea86:~/lind-wasm$ src/wasmtime/target/debug/wasmtime run --allow-precompiled --wasi threads=y --wasi preview2=n  tests/unit-tests/process_tests/deterministic/forkdup.cwasm
I'm the child
back to stdout

thread 'lind-fork-2' panicked at crates/rawposix/src/interface/signal.rs:27:9:
null pointer dereference occurred
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread caused non-unwinding panic. aborting.
Aborted (core dumped)

Besides those, could we also document command lines to use this feature at somewhere?

@rennergade
Copy link
Contributor Author

@Yaxuan-w I think my last commits fixes the bug you mentioned. I'm going to look into the documentation but as discussed today we may want to do some general modifications.

@rennergade rennergade mentioned this pull request Jul 29, 2025
Yaxuan-w
Yaxuan-w previously approved these changes Jul 29, 2025
Copy link
Member

@Yaxuan-w Yaxuan-w left a comment

Choose a reason for hiding this comment

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

Thanks for doing this!

@rennergade
Copy link
Contributor Author

@qianxichen233 can you review this?

unsafe { *epoch }
#[cfg(feature = "disable_signals")]
{
return 1; // if were disabling signals this function is unescessary so we avoid a potential null ptr dereference
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems like a very rough and unstable solution for me. A better way to handle this might be to wrap all the places where get_epoch_state is called within a cfg block as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay I updated it, does this seem better?

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.

3 participants