Skip to content

thread '<unnamed>' panicked at 'attempt to subtract with overflow' #124

@ttiimm

Description

@ttiimm

I'm hitting an issue trying to run simple-server=0.4.0 on Apple M2 hardware. I get this failure when trying to run the example, then making a request. I know the architecture isn't fully supported yet, but thought I'd bring the issue up.

Rust and Cargo versions

$ rustc -V
rustc 1.63.0 (4b91a6ea7 2022-08-08)

$ cargo -V
cargo 1.63.0 (fd9c4297c 2022-07-01)

Steps to Reproduce

  1. Run the example. $ RUST_BACKTRACE=1 UST_LOG="simple_server=info" cargo run
  2. Make a request to the server. $ curl localhost:7878

Note: also tried compiling with --target x86_64-apple-darwin option, but similar failure observed.

Another note: when running with version 0.3.0 I receive this message on the client side.

$ curl -v localhost:7878
*   Trying 127.0.0.1:7878...
* Connected to localhost (127.0.0.1) port 7878 (#0)
> GET / HTTP/1.1
> Host: localhost:7878
> User-Agent: curl/7.79.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
* no chunk, no close, no size. Assume close to signal end
<
* Closing connection 0
Hello Rust!%

Result

thread '<unnamed>' panicked at 'attempt to subtract with overflow', /Users/tim/.cargo/registry/src/github.com-1ecc6299db9ec823/simple-server-0.4.0/src/parsing.rs:75:17
stack backtrace:
   0: rust_begin_unwind
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:584:5
   1: core::panicking::panic_fmt
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/panicking.rs:142:14
   2: core::panicking::panic
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/panicking.rs:48:5
   3: simple_server::parsing::slice_indices
             at /Users/tim/.cargo/registry/src/github.com-1ecc6299db9ec823/simple-server-0.4.0/src/parsing.rs:75:17
   4: simple_server::parsing::try_parse_request::{{closure}}
             at /Users/tim/.cargo/registry/src/github.com-1ecc6299db9ec823/simple-server-0.4.0/src/parsing.rs:94:30
   5: core::option::Option<T>::map
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/option.rs:929:29
   6: simple_server::parsing::try_parse_request
             at /Users/tim/.cargo/registry/src/github.com-1ecc6299db9ec823/simple-server-0.4.0/src/parsing.rs:88:9
   7: simple_server::request::read
             at /Users/tim/.cargo/registry/src/github.com-1ecc6299db9ec823/simple-server-0.4.0/src/request.rs:29:23
   8: simple_server::Server::handle_connection
             at /Users/tim/.cargo/registry/src/github.com-1ecc6299db9ec823/simple-server-0.4.0/src/lib.rs:342:29
   9: simple_server::Server::listen_on_socket::{{closure}}::{{closure}}
             at /Users/tim/.cargo/registry/src/github.com-1ecc6299db9ec823/simple-server-0.4.0/src/lib.rs:266:21
  10: <F as scoped_threadpool::FnBox>::call_box
             at /Users/tim/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped_threadpool-0.1.9/src/lib.rs:71:9
  11: scoped_threadpool::Pool::new::{{closure}}
             at /Users/tim/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped_threadpool-0.1.9/src/lib.rs:127:29
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
thread 'main' panicked at 'Thread pool worker panicked', /Users/tim/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped_threadpool-0.1.9/src/lib.rs:236:13
stack backtrace:
   0: std::panicking::begin_panic
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:616:12
   1: scoped_threadpool::Scope::join_all
             at /Users/tim/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped_threadpool-0.1.9/src/lib.rs:236:13
   2: <scoped_threadpool::Scope as core::ops::drop::Drop>::drop
             at /Users/tim/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped_threadpool-0.1.9/src/lib.rs:248:9
   3: core::ptr::drop_in_place<scoped_threadpool::Scope>
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/ptr/mod.rs:487:1
   4: scoped_threadpool::Pool::scoped
             at /Users/tim/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped_threadpool-0.1.9/src/lib.rs:182:5
   5: simple_server::Server::listen_on_socket
             at /Users/tim/.cargo/registry/src/github.com-1ecc6299db9ec823/simple-server-0.4.0/src/lib.rs:264:13
   6: simple_server::Server::listen
             at /Users/tim/.cargo/registry/src/github.com-1ecc6299db9ec823/simple-server-0.4.0/src/lib.rs:216:9
   7: sub_bug::main
             at ./main.rs:20:5
   8: core::ops::function::FnOnce::call_once
             at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
tim:src$ RUST_BACKTRACE=full RUST_LOG="simple_server=info" cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.02s
     Running `/Users/tim/Projects/sub-bug/target/debug/sub-bug`
[2022-09-22T02:23:48Z INFO  simple_server] Server started at http://127.0.0.1:7878
thread '<unnamed>' panicked at 'attempt to subtract with overflow', /Users/tim/.cargo/registry/src/github.com-1ecc6299db9ec823/simple-server-0.4.0/src/parsing.rs:75:17
stack backtrace:
   0:        0x104c80044 - std::backtrace_rs::backtrace::libunwind::trace::hd589abd6c35ac4ad
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:        0x104c80044 - std::backtrace_rs::backtrace::trace_unsynchronized::h98ffcaaa5ca3fa1b
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:        0x104c80044 - std::sys_common::backtrace::_print_fmt::h6d737d3ee2f9b02c
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:66:5
   3:        0x104c80044 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h188b7ef1c7993e78
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:45:22
   4:        0x104c946e0 - core::fmt::write::he84a3004e7af3f34
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/fmt/mod.rs:1197:17
   5:        0x104c7c320 - std::io::Write::write_fmt::h9370b50affaab0be
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/io/mod.rs:1672:15
   6:        0x104c81790 - std::sys_common::backtrace::_print::h6a312acaf6239500
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:48:5
   7:        0x104c81790 - std::sys_common::backtrace::print::h8d70f4e1fc358fa6
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:35:9
   8:        0x104c81790 - std::panicking::default_hook::{{closure}}::hc074f8023cce83ca
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:295:22
   9:        0x104c814f8 - std::panicking::default_hook::hef854b51b9b79ff2
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:314:9
  10:        0x104c81c28 - std::panicking::rust_panic_with_hook::h1e59e224d558a492
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:698:17
  11:        0x104c81b24 - std::panicking::begin_panic_handler::{{closure}}::he1a9d6ab32bfd8c6
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:586:13
  12:        0x104c80520 - std::sys_common::backtrace::__rust_end_short_backtrace::he9b94791b02f48cd
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:138:18
  13:        0x104c818b4 - rust_begin_unwind
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:584:5
  14:        0x104c9e7d4 - core::panicking::panic_fmt::h9fec86f6a9c4146e
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/panicking.rs:142:14
  15:        0x104c9e6f4 - core::panicking::panic::h02e9fc642940f2ec
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/panicking.rs:48:5
  16:        0x104a89734 - simple_server::parsing::slice_indices::hc3c776bbe929cb8b
                               at /Users/tim/.cargo/registry/src/github.com-1ecc6299db9ec823/simple-server-0.4.0/src/parsing.rs:75:17
  17:        0x104a89d44 - simple_server::parsing::try_parse_request::{{closure}}::h9fe53280499b300c
                               at /Users/tim/.cargo/registry/src/github.com-1ecc6299db9ec823/simple-server-0.4.0/src/parsing.rs:94:30
  18:        0x104a8cb74 - core::option::Option<T>::map::hda636feb7f6dc9d9
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/option.rs:929:29
  19:        0x104a89974 - simple_server::parsing::try_parse_request::h3b6e4200170f46d1
                               at /Users/tim/.cargo/registry/src/github.com-1ecc6299db9ec823/simple-server-0.4.0/src/parsing.rs:88:9
  20:        0x104a93344 - simple_server::request::read::ha76989050445174e
                               at /Users/tim/.cargo/registry/src/github.com-1ecc6299db9ec823/simple-server-0.4.0/src/request.rs:29:23
  21:        0x104a8f038 - simple_server::Server::handle_connection::h21baa854353235a7
                               at /Users/tim/.cargo/registry/src/github.com-1ecc6299db9ec823/simple-server-0.4.0/src/lib.rs:342:29
  22:        0x104a8ee14 - simple_server::Server::listen_on_socket::{{closure}}::{{closure}}::h07765d107bb2ed9c
                               at /Users/tim/.cargo/registry/src/github.com-1ecc6299db9ec823/simple-server-0.4.0/src/lib.rs:266:21
  23:        0x104a8e8e4 - <F as scoped_threadpool::FnBox>::call_box::h0cc54b5b40dd4c90
                               at /Users/tim/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped_threadpool-0.1.9/src/lib.rs:71:9
  24:        0x104aac9ec - scoped_threadpool::Pool::new::{{closure}}::h34e0f79f9eb4a6e4
                               at /Users/tim/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped_threadpool-0.1.9/src/lib.rs:127:29
  25:        0x104aaa4ec - std::sys_common::backtrace::__rust_begin_short_backtrace::h2e03fc55c4c75cf5
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:122:18
  26:        0x104ac98e0 - std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}}::h74d4c2061fde0796
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/thread/mod.rs:505:17
  27:        0x104aaf7e0 - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::hf68d20fa7c37ed28
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/panic/unwind_safe.rs:271:9
  28:        0x104ab53fc - std::panicking::try::do_call::h764f00442f379600
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:492:40
  29:        0x104aba110 - ___rust_try
  30:        0x104ab5278 - std::panicking::try::h4112cb0ecbd1fa47
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:456:19
  31:        0x104ab5134 - std::panic::catch_unwind::h81ffba7c9f2a3029
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panic.rs:137:14
  32:        0x104ac9760 - std::thread::Builder::spawn_unchecked_::{{closure}}::h85fbef53653ecb7c
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/thread/mod.rs:504:30
  33:        0x104ab578c - core::ops::function::FnOnce::call_once{{vtable.shim}}::h60c2625151a0f6cc
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/ops/function.rs:248:5
  34:        0x104c83ea0 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h89934fef96b83268
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/alloc/src/boxed.rs:1951:9
  35:        0x104c83ea0 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h2c579033340f7d2e
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/alloc/src/boxed.rs:1951:9
  36:        0x104c83ea0 - std::sys::unix::thread::Thread::new::thread_start::h7b2f9b83fb320a20
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys/unix/thread.rs:108:17
  37:        0x1b5ecc26c - __pthread_deallocate
thread 'main' panicked at 'Thread pool worker panicked', /Users/tim/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped_threadpool-0.1.9/src/lib.rs:236:13
stack backtrace:
   0:        0x104c80044 - std::backtrace_rs::backtrace::libunwind::trace::hd589abd6c35ac4ad
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:        0x104c80044 - std::backtrace_rs::backtrace::trace_unsynchronized::h98ffcaaa5ca3fa1b
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:        0x104c80044 - std::sys_common::backtrace::_print_fmt::h6d737d3ee2f9b02c
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:66:5
   3:        0x104c80044 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h188b7ef1c7993e78
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:45:22
   4:        0x104c946e0 - core::fmt::write::he84a3004e7af3f34
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/fmt/mod.rs:1197:17
   5:        0x104c7c320 - std::io::Write::write_fmt::h9370b50affaab0be
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/io/mod.rs:1672:15
   6:        0x104c81790 - std::sys_common::backtrace::_print::h6a312acaf6239500
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:48:5
   7:        0x104c81790 - std::sys_common::backtrace::print::h8d70f4e1fc358fa6
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:35:9
   8:        0x104c81790 - std::panicking::default_hook::{{closure}}::hc074f8023cce83ca
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:295:22
   9:        0x104c814f8 - std::panicking::default_hook::hef854b51b9b79ff2
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:314:9
  10:        0x104c81c28 - std::panicking::rust_panic_with_hook::h1e59e224d558a492
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:698:17
  11:        0x104ab51e4 - std::panicking::begin_panic::{{closure}}::h7aa8fbd1e0dbbff5
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:617:9
  12:        0x104aaa498 - std::sys_common::backtrace::__rust_end_short_backtrace::hf579749161a515aa
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:138:18
  13:        0x104c9998c - std::panicking::begin_panic::h1a2b26fbbb829b3e
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:616:12
  14:        0x104aacca8 - scoped_threadpool::Scope::join_all::hece099d905b0a738
                               at /Users/tim/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped_threadpool-0.1.9/src/lib.rs:236:13
  15:        0x104aacd3c - <scoped_threadpool::Scope as core::ops::drop::Drop>::drop::hf0bd3d47223e93b1
                               at /Users/tim/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped_threadpool-0.1.9/src/lib.rs:248:9
  16:        0x104a8bad0 - core::ptr::drop_in_place<scoped_threadpool::Scope>::hb3e01b8d290b1f38
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/ptr/mod.rs:487:1
  17:        0x104a8a074 - scoped_threadpool::Pool::scoped::hf779aafe3b4aa319
                               at /Users/tim/.cargo/registry/src/github.com-1ecc6299db9ec823/scoped_threadpool-0.1.9/src/lib.rs:182:5
  18:        0x104a8ed80 - simple_server::Server::listen_on_socket::h8efaa5ce35c92603
                               at /Users/tim/.cargo/registry/src/github.com-1ecc6299db9ec823/simple-server-0.4.0/src/lib.rs:264:13
  19:        0x104a8eb1c - simple_server::Server::listen::h14cb3c271696b297
                               at /Users/tim/.cargo/registry/src/github.com-1ecc6299db9ec823/simple-server-0.4.0/src/lib.rs:216:9
  20:        0x104a83490 - sub_bug::main::h4aec0d84fca3fb8f
                               at /Users/tim/Projects/sub-bug/src/main.rs:20:5
  21:        0x104a83c68 - core::ops::function::FnOnce::call_once::h8626f35a81e27db4
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/ops/function.rs:248:5
  22:        0x104a844dc - std::sys_common::backtrace::__rust_begin_short_backtrace::hfaa75fdf811ede2b
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/sys_common/backtrace.rs:122:18
  23:        0x104a83564 - std::rt::lang_start::{{closure}}::h693ee15618a2ca4e
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/rt.rs:145:18
  24:        0x104c78000 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h6091bdce585e0c9c
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/core/src/ops/function.rs:280:13
  25:        0x104c78000 - std::panicking::try::do_call::h2dde559bd47c537c
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:492:40
  26:        0x104c78000 - std::panicking::try::h0be0a0414f498150
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:456:19
  27:        0x104c78000 - std::panic::catch_unwind::h0dbebda9c8fcb6e3
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panic.rs:137:14
  28:        0x104c78000 - std::rt::lang_start_internal::{{closure}}::h70683b79d9154b98
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/rt.rs:128:48
  29:        0x104c78000 - std::panicking::try::do_call::h60888734191539e8
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:492:40
  30:        0x104c78000 - std::panicking::try::h212200e2cf152f8d
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panicking.rs:456:19
  31:        0x104c78000 - std::panic::catch_unwind::hf4ae91ebdc2dedaf
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/panic.rs:137:14
  32:        0x104c78000 - std::rt::lang_start_internal::h92a00ef694077615
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/rt.rs:128:20
  33:        0x104a8352c - std::rt::lang_start::h00b3962a31a0c1d3
                               at /rustc/4b91a6ea7258a947e59c6522cd5898e7c0a6a88f/library/std/src/rt.rs:144:17
  34:        0x104a834e0 - _main

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions