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

generate_random_id causes panic with a lot of concurrent requests #309

Open
griffi-gh opened this issue Feb 1, 2025 · 2 comments
Open

Comments

@griffi-gh
Copy link

griffi-gh commented Feb 1, 2025

grammers version: git, 3d0b640

thread 'tokio-runtime-worker' panicked at /home/user/.cargo/git/checkouts/grammers-.../.../lib/grammers-mtsender/src/lib.rs:84:14
called `Result::unwrap()` on an `Err` value: 1738451223170673220

backtrace:

stack backtrace:
   0: rust_begin_unwind
             at /rustc/b1a7dfb91106018f47ed9dc9b27aee1977682868/library/std/src/panicking.rs:692:5
   1: core::panicking::panic_fmt
             at /rustc/b1a7dfb91106018f47ed9dc9b27aee1977682868/library/core/src/panicking.rs:75:14
   2: core::result::unwrap_failed
             at /rustc/b1a7dfb91106018f47ed9dc9b27aee1977682868/library/core/src/result.rs:1704:5
   3: core::result::Result<T,E>::unwrap
             at /nix/store/zs37f02gamiz3v5z83lqkq3n99rdgvw0-rust-nightly-complete-with-components-2025-01-11/lib/rustlib/src/rust/library/core/src/result.rs:1109:23
   4: grammers_mtsender::generate_random_id
             at .../grammers-.../.../lib/grammers-mtsender/src/lib.rs:82:9
   5: grammers_mtsender::Sender<T,M>::on_ping_timeout
             at .../grammers-.../.../lib/grammers-mtsender/src/lib.rs:459:23
   6: grammers_mtsender::Sender<T,MRayon: detected unexpected panic; aborting
>::step::{{closure}}
             at .../grammers-.../.../lib/grammers-mtsender/src/lib.rs:291:17
@griffi-gh griffi-gh changed the title LAST_ID causes crash with a lot of concurrent requests generate_random_id causes panic with a lot of concurrent requests Feb 1, 2025
@Lonami
Copy link
Owner

Lonami commented Feb 2, 2025

My understanding of atomics was that this couldn't really happen, but that's clearly flawed. Since you seem able to reproduce the issue, would you mind attempting a fix and sending a PR? Perhaps we can just replace it with a Mutex? But if you know of a way to make it work with atomics, that'd be great.

@griffi-gh
Copy link
Author

griffi-gh commented Feb 2, 2025

i just ended up patching the crate to ignore the error for my project, but a proper solution would be nice

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