Skip to content

Bug running in debug mode in cargo #41

@fahdfady

Description

@fahdfady

there's some weird error pops out when running metassr with cargo run in debug mode. something related to unsafe:

[metassr-dev]:~/metassr$ cargo run -- --root ./tests/web-app/ build
warning: /home/fahdashour/metassr/Cargo.toml: only one of `license` or `license-file` is necessary
`license` should be used if the package license can be expressed with a standard SPDX expression.
`license-file` should be used if the package uses a non-standard license.
See https://doc.rust-lang.org/cargo/reference/manifest.html#the-license-and-license-file-fields for more information.
   Compiling regex-automata v0.1.10
warning: unused variable: `params`
  --> crates/metassr-server/src/handler.rs:48:29
   |
48 |                 move |Query(params): Query<HashMap<String, String>>,
   |                             ^^^^^^ help: if this is intentional, prefix it with an underscore: `_params`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: unused variable: `path`
  --> crates/metassr-server/src/handler.rs:49:28
   |
49 |                       Path(path): Path<HashMap<String, String>>| async move {
   |                            ^^^^ help: if this is intentional, prefix it with an underscore: `_path`

warning: `metassr-server` (lib) generated 2 warnings
   Compiling matchers v0.1.0
   Compiling tracing-subscriber v0.3.18
   Compiling logger v0.0.1-alpha (/home/fahdashour/metassr/crates/logger)
   Compiling metassr v0.0.1-alpha (/home/fahdashour/metassr)
warning: unused variable: `instant`
  --> metassr-cli/src/cli/builder.rs:29:13
   |
29 |         let instant = Instant::now();
   |             ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_instant`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: `metassr` (bin "metassr") generated 1 warning
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 8.88s
     Running `target/debug/metassr --root ./tests/web-app/ build`

thread '<unnamed>' panicked at library/core/src/panicking.rs:225:5:
unsafe precondition(s) violated: NonNull::new_unchecked requires that the pointer is non-null

This indicates a bug in the program. This Undefined Behavior check is optional, and cannot be relied on for safety.
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread caused non-unwinding panic. aborting.
Stack trace (most recent call last) in thread 58799:
#31   Object "/gnu/store/9ygpsbp5gfbrwrin5jdmkd3m84vdsai5-libuv-1.49.1/lib/libuv.so.1", at 0x7f2298049275, in uv_run
#30   Object "/gnu/store/9ygpsbp5gfbrwrin5jdmkd3m84vdsai5-libuv-1.49.1/lib/libuv.so.1", at 0x7f229805b7a2, in 
#29   Object "/gnu/store/9ygpsbp5gfbrwrin5jdmkd3m84vdsai5-libuv-1.49.1/lib/libuv.so.1", at 0x7f22980486c2, in 
#28   Object "/gnu/store/3611k5c6iki74mzrp2lj670kv7csp0wh-libnode-22.12.0/lib/libnode.so.127", at 0x7f2240988424, in 
#27   Object "/gnu/store/3611k5c6iki74mzrp2lj670kv7csp0wh-libnode-22.12.0/lib/libnode.so.127", at 0x7f22408cbd96, in node::CallbackScope::~CallbackScope()
#26   Object "/gnu/store/3611k5c6iki74mzrp2lj670kv7csp0wh-libnode-22.12.0/lib/libnode.so.127", at 0x7f22408cbd30, in node::InternalCallbackScope::~InternalCallbackScope()
#25   Object "/gnu/store/3611k5c6iki74mzrp2lj670kv7csp0wh-libnode-22.12.0/lib/libnode.so.127", at 0x7f22408cbaf8, in node::InternalCallbackScope::Close()
#24   Object "/gnu/store/3611k5c6iki74mzrp2lj670kv7csp0wh-libnode-22.12.0/lib/libnode.so.127", at 0x7f224117cf8e, in v8::internal::MicrotaskQueue::PerformCheckpointInternal(v8::Isolate*)
#23   Object "/gnu/store/3611k5c6iki74mzrp2lj670kv7csp0wh-libnode-22.12.0/lib/libnode.so.127", at 0x7f224117cc55, in v8::internal::MicrotaskQueue::RunMicrotasks(v8::internal::Isolate*)
#22   Object "/gnu/store/3611k5c6iki74mzrp2lj670kv7csp0wh-libnode-22.12.0/lib/libnode.so.127", at 0x7f224114d2e9, in v8::internal::Execution::TryRunMicrotasks(v8::internal::Isolate*, v8::internal::MicrotaskQueue*)
#21   Object "/gnu/store/3611k5c6iki74mzrp2lj670kv7csp0wh-libnode-22.12.0/lib/libnode.so.127", at 0x7f224114c185, in 
#20   Object "[0x7f21e0c8b402]", at 0x7f21e0c8b402, in 
#19   Object "[0x7f21e0cbc918]", at 0x7f21e0cbc918, in 
#18   Object "[0x7f21e0dab274]", at 0x7f21e0dab274, in 
#17   Object "[0x7f21e0c8d8dd]", at 0x7f21e0c8d8dd, in 
#16   Object "[0x7f21e0c8f5e1]", at 0x7f21e0c8f5e1, in 
#15   Object "/gnu/store/3611k5c6iki74mzrp2lj670kv7csp0wh-libnode-22.12.0/lib/libnode.so.127", at 0x7f2240962334, in 
#14   Object "/gnu/store/lq4c37dxvbd8f4g5b7p0flf2w05s3h9r-metacall-0.9.14/lib/libnode_loader.so", at 0x7f2248d6bab9, in 
#13   Object "/gnu/store/lq4c37dxvbd8f4g5b7p0flf2w05s3h9r-metacall-0.9.14/lib/libnode_loader.so", at 0x7f2248d64288, in 
#12   Object "target/debug/metassr", at 0x564f2d6a8826, in 
#11   Object "target/debug/metassr", at 0x564f2d6980cf, in 
#10   Object "target/debug/metassr", at 0x564f2d6a6b8c, in 
#9    Object "target/debug/metassr", at 0x564f2d809791, in 
#8    Object "target/debug/metassr", at 0x564f2d8096fc, in 
#7    Object "target/debug/metassr", at 0x564f2d7e849c, in 
#6    Object "target/debug/metassr", at 0x564f2d7e71a8, in 
#5    Object "target/debug/metassr", at 0x564f2d7e87d5, in 
#4    Object "target/debug/metassr", at 0x564f2d7e8bf2, in 
#3    Object "target/debug/metassr", at 0x564f2d7eabc9, in 
#2    Object "/lib/x86_64-linux-gnu/libc.so.6", at 0x7f229ab968fe, in abort
#1    Object "/lib/x86_64-linux-gnu/libc.so.6", at 0x7f229abb327d, in gsignal
#0    Object "/lib/x86_64-linux-gnu/libc.so.6", at 0x7f229ac0cb2c, in pthread_kill
Aborted (Signal sent by tkill() 58302 1000)
Aborted (core dumped)

For some reason, this doesn't happen in release mode, even with the same exact command just with -r in it:

fahdashour:~/metassr$ cargo run -r -- --root ./tests/web-app/ build
warning: /home/fahdashour/metassr/Cargo.toml: only one of `license` or `license-file` is necessary
`license` should be used if the package license can be expressed with a standard SPDX expression.
`license-file` should be used if the package uses a non-standard license.
See https://doc.rust-lang.org/cargo/reference/manifest.html#the-license-and-license-file-fields for more information.
warning: unused variable: `params`
  --> crates/metassr-server/src/handler.rs:48:29
   |
48 |                 move |Query(params): Query<HashMap<String, String>>,
   |                             ^^^^^^ help: if this is intentional, prefix it with an underscore: `_params`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: unused variable: `path`
  --> crates/metassr-server/src/handler.rs:49:28
   |
49 |                       Path(path): Path<HashMap<String, String>>| async move {
   |                            ^^^^ help: if this is intentional, prefix it with an underscore: `_path`

warning: `metassr-server` (lib) generated 2 warnings
warning: unused variable: `instant`
  --> metassr-cli/src/cli/builder.rs:29:13
   |
29 |         let instant = Instant::now();
   |             ^^^^^^^ help: if this is intentional, prefix it with an underscore: `_instant`
   |
   = note: `#[warn(unused_variables)]` on by default

warning: `metassr` (bin "metassr") generated 1 warning
    Finished `release` profile [optimized] target(s) in 0.21s
     Running `target/release/metassr --root ./tests/web-app/ build`
2025-09-11T09:32:24.142867781+03:00  INFO [builder] Client building is completed time: 448ms 
2025-09-11T09:32:24.252963111+03:00  INFO [builder] Server building is completed time: 110ms 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions