-
Notifications
You must be signed in to change notification settings - Fork 480
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
Panicked during epoch::pin()
#1042
Comments
In what environment did you encounter this problem? Do you have an example to reproduce this problem?
I have never seen this problem, but assuming you are using a 64-bit system, it would take years to cause an overflow due to addition, so I guess it is more likely an overflow due to subtraction caused by an incorrect invocation of unpin. If so, it's either a bug on our code, a bug in the standard library or platform (especially around thread-local), or a bug in your code, but if you're not using unsafe code, it's one of the former two. |
If you have encountered rust-lang/rust#47949 (rustc bug) in some way, I think it is possible to trigger this problem because the destructor of the guard in repin_after will not be called. I can't immediately think of an example that would trigger it, though. |
Thanks you very much, I'm trying to get a backtrace of the panic currently. I can't reproduce it with a small example, which makes it hard to debug. |
Hi, I want to thanks for your help in previous communications. After a clear inspect of the source code, I have another two question about the
pub(crate) fn pin(&self) -> Guard {
let guard = Guard { local: self };
let guard_count = self.guard_count.get();
self.guard_count.set(guard_count.checked_add(1).unwrap());
if guard_count == 0 {
pub(crate) fn unpin(&self) {
let guard_count = self.guard_count.get();
self.guard_count.set(guard_count - 1);
if guard_count == 1 {
self.epoch.store(Epoch::starting(), Ordering::Release);
if self.handle_count.get() == 0 {
self.finalize();
}
}
} |
Now I managed to reproduce this but several times, sometimes it panicked in the overflow of 😢 totally confused. |
@taiki-e Could you please help us with the above question? Thank you so much. |
Getting a value, then adding or subtracting it, and then checking the old value is the same idiom as fetch_add or fetch_sub. In the former case,
It checks handle_count, not guard_count. (If there is a live handle, finalize cannot be called.) |
Is it possible to provide this reproduction? If this is difficult, at least please provide us information about your build environment, build configuration, other dependencies, and any unsafe code you may have. TBH I feel it is impossible to help you with just the information currently provided. |
Indeed, we are diligently analyzing our code but have yet to uncover significant findings. Concurrently, we're delving into the intricacies of Crossbeam's code to gain a deeper understanding. During this process, we may occasionally seek your assistance with questions like those previously mentioned. We genuinely appreciate your support and guidance in these matters. |
I came across a weird panic recently, which seems is the
guard_count: usize
has overflowed during callingepoch::pin()
. But I'm sure I haven't callepoch::pin()
that many times.I'm wondering if this ever occurred you guys, and could kindly provides some insights on this issue.
The relevant code context are
crossbeam/crossbeam-epoch/src/internal.rs
Lines 380 to 387 in 18afbb6
The text was updated successfully, but these errors were encountered: