Skip to content
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

#[debug_handler] causes invalid memory reference error #1129

Closed
qwright10 opened this issue Jun 29, 2022 · 5 comments
Closed

#[debug_handler] causes invalid memory reference error #1129

qwright10 opened this issue Jun 29, 2022 · 5 comments

Comments

@qwright10
Copy link

Bug Report

Version

axum v0.5.10
— axum-core v0.2.6
axum-macros v0.2.3

Platform

Linux Desktop 5.10.102.1-microsoft-standard-WSL2 #1 SMP Wed Mar 2 00:30:59 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

WSL2 Ubuntu 22.04

Crates

axum-macros

Description

When trying to debug "handler doesn't implement Handler" issues using #[debug_handler], the following error is printed by cargo build:

   Compiling api v0.1.0 (/home/wrightq00/quizzr/packages/api)
/home/wrightq00/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-2c37baf9e5f6ef22.so(+0x49b7f3)[0x7f201929b7f3]
/lib/x86_64-linux-gnu/libc.so.6(+0x42520)[0x7f201881a520]
/home/wrightq00/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-2c37baf9e5f6ef22.so(_RNvMs8_NtCs9O00EjNyc7q_10rustc_span6symbolNtB5_6Symbol6intern+0x7c)[0x7f201b15cc7c]
/home/wrightq00/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-2c37baf9e5f6ef22.so(_RNvMs3_NtNtNtCslhYLE3SgC0D_14rustc_metadata5rmeta7decoder11cstore_implNtNtBb_7creader6CStore20load_macro_untracked+0x55d)[0x7f201b809c9d]
/home/wrightq00/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-2c37baf9e5f6ef22.so(_RNvMs_NtCsaXZfUu12cuT_13rustc_resolve6macrosNtB6_8Resolver18resolve_macro_path+0x845)[0x7f201a832295]
/home/wrightq00/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-2c37baf9e5f6ef22.so(_RNvXNtCsaXZfUu12cuT_13rustc_resolve6macrosNtB4_8ResolverNtNtCsiPV1BOyaf7X_12rustc_expand4base14ResolverExpand24resolve_macro_invocation+0x1b6)[0x7f201a82f6e6]
/home/wrightq00/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-2c37baf9e5f6ef22.so(_RNvMs1_NtCsiPV1BOyaf7X_12rustc_expand6expandNtB5_13MacroExpander21fully_expand_fragment+0x377)[0x7f201adb5407]
/home/wrightq00/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-2c37baf9e5f6ef22.so(_RNvMs1_NtCsiPV1BOyaf7X_12rustc_expand6expandNtB5_13MacroExpander12expand_crate+0x29e)[0x7f201b88289e]
/home/wrightq00/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-2c37baf9e5f6ef22.so(+0x23b74ef)[0x7f201b1b74ef]
/home/wrightq00/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-2c37baf9e5f6ef22.so(+0x23ab751)[0x7f201b1ab751]
/home/wrightq00/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-2c37baf9e5f6ef22.so(_RNvMs0_NtCs7iD4cN4Y90F_15rustc_interface7queriesNtB5_7Queries9expansion+0x2a1)[0x7f201b1da091]
/home/wrightq00/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-2c37baf9e5f6ef22.so(+0x238f979)[0x7f201b18f979]
/home/wrightq00/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-2c37baf9e5f6ef22.so(+0x237503f)[0x7f201b17503f]
/home/wrightq00/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-2c37baf9e5f6ef22.so(+0x23910a4)[0x7f201b1910a4]
/home/wrightq00/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-2c37baf9e5f6ef22.so(+0x23737c2)[0x7f201b1737c2]
/home/wrightq00/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-2c37baf9e5f6ef22.so(+0x238938f)[0x7f201b18938f]
/home/wrightq00/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/librustc_driver-2c37baf9e5f6ef22.so(+0x2374af9)[0x7f201b174af9]
/home/wrightq00/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/../lib/libstd-05b39ac0cb4c5688.so(rust_metadata_std_3b302b3c9093c22+0xabbf3)[0x7f2018aabbf3]
/lib/x86_64-linux-gnu/libc.so.6(+0x94b43)[0x7f201886cb43]
/lib/x86_64-linux-gnu/libc.so.6(+0x126a00)[0x7f20188fea00]
error: could not compile `api`

Caused by:
  process didn't exit successfully: `rustc --crate-name api --edition=2021 src/main.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type bin --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 -C metadata=8d5d6ba666288322 -C extra-filename=-8d5d6ba666288322 --out-dir /home/wrightq00/quizzr/packages/api/target/debug/deps -C incremental=/home/wrightq00/quizzr/packages/api/target/debug/incremental -L dependency=/home/wrightq00/quizzr/packages/api/target/debug/deps --extern anyhow=/home/wrightq00/quizzr/packages/api/target/debug/deps/libanyhow-c2d46bf4d9398799.rlib --extern axum=/home/wrightq00/quizzr/packages/api/target/debug/deps/libaxum-1387676e23dc0257.rlib --extern axum_macros=/home/wrightq00/quizzr/packages/api/target/debug/deps/libaxum_macros-7c28b204011ee148.so --extern chrono=/home/wrightq00/quizzr/packages/api/target/debug/deps/libchrono-d0fc0550837e8143.rlib --extern dotenv=/home/wrightq00/quizzr/packages/api/target/debug/deps/libdotenv-50bb7697d532cbce.rlib --extern serde=/home/wrightq00/quizzr/packages/api/target/debug/deps/libserde-e7bed94eea9b213f.rlib --extern serde_json=/home/wrightq00/quizzr/packages/api/target/debug/deps/libserde_json-8f8a9907553440d6.rlib --extern sqlx=/home/wrightq00/quizzr/packages/api/target/debug/deps/libsqlx-d4a6a28e0e0d4510.rlib --extern tokio=/home/wrightq00/quizzr/packages/api/target/debug/deps/libtokio-c221eff87fef0848.rlib --extern tracing=/home/wrightq00/quizzr/packages/api/target/debug/deps/libtracing-b081070ae994a1b9.rlib --extern tracing_subscriber=/home/wrightq00/quizzr/packages/api/target/debug/deps/libtracing_subscriber-d08bc8617481553b.rlib -L native=/home/wrightq00/quizzr/packages/api/target/debug/build/ring-92e5bb2bbc96a21b/out` (signal: 11, SIGSEGV: invalid memory reference)

A simplified version of affected code:

#[tokio::main]
async fn main() {
    let app = Router::new()
        .route("/", get(root));

    Server::bind(&addr)
        .serve(app.make_into_service())
        .await
        .unwrap();
}

#[axum_macros::debug_handler] // vscode also marks this with "proc macro `debug_handler` not expanded: server exited"
async fn root() -> &'static str {
    "Hello, world!"
)
@davidpdrsn
Copy link
Member

I cannot reproduce it. Works fine for me 🤔

use axum::{routing::get, Router, Server};

#[tokio::main]
async fn main() {
    let app = Router::new().route("/", get(root));

    Server::bind(&"0.0.0.0:3000".parse().unwrap())
        .serve(app.into_make_service())
        .await
        .unwrap();
}

#[axum_macros::debug_handler]
async fn root() -> &'static str {
    "Hello, world!"
}
[package]
name = "foo"
version = "0.1.0"
edition = "2021"

[dependencies]
axum = "0.5.10"
axum-core = "0.2.6"
axum-macros = "0.2.3"
tokio = { version = "1.0", features = ["full"] }

// vscode also marks this with "proc macro debug_handler not expanded: server exited"

That message is from rust-analyzer. I don't exactly know why it only appears sometimes but I don't believe there is anything we can do about it.

@davidpdrsn
Copy link
Member

Sorry didn't mean to close quite yet.

@qwright10
Copy link
Author

This seems to only occur on WSL; it works fine on both macOS Ventura and Windows 11.

@davidpdrsn
Copy link
Member

Oh okay. That's odd. Are you sure you were using the same versions? Isn't WSL "just Linux"? How could it not work just there? 🤷‍♂️

I don't have access to a machine with WSL so can't test it.

@davidpdrsn
Copy link
Member

I'm sorry but I will close this. I doubt this has anything to do with axum. There is no unsafe so I don't see how invalid memory references are possible. I don't have access to a windows box myself but heard from someone in the discord who says they cannot reproduce it.

I recommend you ask in the rust-lang users forum if you keep having this issue.

@davidpdrsn davidpdrsn closed this as not planned Won't fix, can't repro, duplicate, stale Jul 2, 2022
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

No branches or pull requests

2 participants