I am writing a proc_macro for the first time, so I have more or less no idea how to track down where the problem is. The code is here and I am running cargo expand on the following code:
use exec_rule::rule;
#[rule(
body = "writeLine('stdout', '*greeting1, *greeting2')",
output = "ExecRuleOut"
)]
#[derive(Debug)]
pub struct VeryAdvancedHelloWorldRule {
pub greeting1: String,
pub greeting2: String,
}
fn main() {
println!("Hello, world!");
}
Specifically, anytime this function is called, I get an error, as I verified with the print statements. The error is:
process didn't exit successfully: `/home/phillipdavis/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc --crate-name exec_rule_test --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,metadata -C embed-bitcode=no -C debuginfo=2 -o /tmp/cargo-expand5Tf5OA/expanded -Zunpretty=expanded -C metadata=1a3cbdbde4116e72 -C extra-filename=-1a3cbdbde4116e72 --out-dir /home/phillipdavis/everyday/dev/rust/grad-proj-gen2/exec_rule_test/target/debug/deps -C incremental=/home/phillipdavis/everyday/dev/rust/grad-proj-gen2/exec_rule_test/target/debug/incremental -L dependency=/home/phillipdavis/everyday/dev/rust/grad-proj-gen2/exec_rule_test/target/debug/deps --extern exec_rule=/home/phillipdavis/everyday/dev/rust/grad-proj-gen2/exec_rule_test/target/debug/deps/libexec_rule-f04a5094cb5df7da.so --extern packe=/home/phillipdavis/everyday/dev/rust/grad-proj-gen2/exec_rule_test/target/debug/deps/libpacke-c0ea201bf258b335.rmeta --extern quick_xml=/home/phillipdavis/everyday/dev/rust/grad-proj-gen2/exec_rule_test/target/debug/deps/libquick_xml-2bc72ae7669b55ba.rmeta --extern rods_prot_msg=/home/phillipdavis/everyday/dev/rust/grad-proj-gen2/exec_rule_test/target/debug/deps/librods_prot_msg-47aeba0a4cfdc4ff.rmeta --extern tokio=/home/phillipdavis/everyday/dev/rust/grad-proj-gen2/exec_rule_test/target/debug/deps/libtokio-0f616be995a16e4d.rmeta` (signal: 11, SIGSEGV: invalid memory reference)
When I first encountered this error, I got an error saying that the stack and blown and stating explicitly that it was a bug, but my something about my debugging efforts made that message disappear and I can't seem to make it return, although I didn't change much substantial about the code. The print statement makes it clear that somehow expand_serialization_impl
is being called repeatedly, despite only ever being called once. Additionally, the error only started when I refactored that function to return a result.
Sorry for the vagueness, but I'm genuinely stumped.