Skip to content

Rust tests#762

Closed
sporksmith wants to merge 2 commits intoshadow:masterfrom
sporksmith:rust-tests
Closed

Rust tests#762
sporksmith wants to merge 2 commits intoshadow:masterfrom
sporksmith:rust-tests

Conversation

@sporksmith
Copy link
Copy Markdown
Contributor

Not intended to be merged in its current state; just for discussion. Follow-up to discussion in #761

Pulls in CMakeRust as a submodule, and creates a hello-world "test" using Rust. This version of it (directly calling libc's write from Rust) works, but aborts or segfaults if we call Rust's println! instead.

Applied these to the Phantom branch, and it works fine there (including using println!)

My inclination is to keep the integration tests (code meant to be run under Shadow) in C for now so that we don't end up writing phantom-only integration tests (nor have to spend time figuring out how to get Rust code running reliably under the elf loader).

The CMakeRust tool used here could be useful though as a way to start to writing Shadow code itself in Rust; especially code that we intend to extract into its own library anyway.

CMakeRust only supports building Rust static libraries, so this uses a
small C wrapper to call the Rust code.

This version of it (calling libc's `write`) succeeds, and causes the
output to be written to the expected log file.

Calling `println!` in the Rust code when running under Shadow results in
the Rust internals calling abort. Running gdb running shadow running the
test results in a segfault when trying to load the plugin.
@sporksmith
Copy link
Copy Markdown
Contributor Author

@robgjansen @rwails for discussion ^

@jtracey
Copy link
Copy Markdown
Contributor

jtracey commented Apr 15, 2020

Back when we were working on elf-loader, there were some attempts to get a plugin written in Rust working:
https://github.com/dhuseby/shadow-rust-test/
(The last bug that I never got around to addressing is #402, almost certainly an elf-loader issue.)

@sporksmith
Copy link
Copy Markdown
Contributor Author

Interesting, thanks! #402 indeed might explain the segfault under gdb; maybe we're "luckily" getting an aligned stack in this case when not running under gdb.

@sporksmith sporksmith closed this Apr 20, 2020
@sporksmith sporksmith deleted the rust-tests branch August 12, 2020 22:38
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.

2 participants