-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Closed
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-incr-compArea: Incremental compilationArea: Incremental compilationC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Hi,
my colleague @Wenceslaw stumbled upon a strange problem when comparing Arc pointers equality. It seems that when constructing trait objects in async functions, sometimes the vtable pointer is different even though the type is the same, leading to Arc::ptr_eq() returning false.
I've put together a minimal-ish example: playground link.
Through some experimentation I've found out the problem occurs when incremental compilation is turned on. On the playground it's off, so you don't see a problem there, but with incremental on, I get an output like this:
[src/main.rs:30] Arc::ptr_eq(&xxx.clone(), &xxx.clone()) = true
[src/main.rs:22] Arc::ptr_eq(&(self.clone() as Arc<dyn Trait>), &other) = true
[src/main.rs:23] fmt_fat_ptr(&*self) = "(55c300209b50, 55c2fe990ea0)"
[src/main.rs:24] fmt_fat_ptr(&*other) = "(55c300209b50, 55c2fe990ea0)"
[src/main.rs:36] Arc::ptr_eq(&xxx.clone(), &xxx.clone()) = true
[src/main.rs:22] Arc::ptr_eq(&(self.clone() as Arc<dyn Trait>), &other) = false
[src/main.rs:23] fmt_fat_ptr(&*self) = "(55c300209b50, 55c2fe990ea0)"
[src/main.rs:24] fmt_fat_ptr(&*other) = "(55c300209b50, 55c2fe991050)"
Toolchain version and optimization level doesn't seem to make any difference.
cc @janbraiins
(edit: typos)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-incr-compArea: Incremental compilationArea: Incremental compilationC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.