You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Listing follows. Note that this is incorrect logic, but I believe that this should not segfault regardless.
The segfault reproduces 100% of the times, on two machines, both on stable and nightly.
use bevy::prelude::*;#[derive(Debug,Clone,Eq,PartialEq,Hash)]pubenumAppState{MainMenu,InGame,}fnmain(){App::build().add_plugins(DefaultPlugins).add_state(AppState::MainMenu).add_state(AppState::InGame).run();}
I suspect there is either a bug somewhere in wgpu's handling of destroying the vulkan context when unwinding causing UB manifesting as SIGSEGV in this case. Or an ordering issue between destorying the vulkan context by wgpu and the X11/Wayland context in winit caused by bevy.
Agreed. @saveriomiroddi does this occur without DefaultPlugins?
Does it occur for other panics, such as the one produced by this snippet?
use bevy::prelude::*;structUninitResource;fnresource_system(res:Res<UninitResource>){}fnmain(){App::build().add_plugins(DefaultPlugins).add_system(resource_system.system()).run();}
Agreed. @saveriomiroddi does this occur without DefaultPlugins?
Does it occur for other panics, such as the one produced by this snippet?
use bevy::prelude::*;structUninitResource;fnresource_system(res:Res<UninitResource>){}fnmain(){App::build().add_plugins(DefaultPlugins).add_system(resource_system.system()).run();}
So!
reference code, without DefaultPlugins -> no segfault;
Okay sweet, so it's probably a GPU / windowing cleanup issue like @bjorn3 commented. If you happen to have other OS's for the same machine installed that would be great, otherwise we can see if we can get other Linux folks to reproduce it.
Okay sweet, so it's probably a GPU / windowing cleanup issue like @bjorn3 commented. If you happen to have other OS's for the same machine installed that would be great, otherwise we can see if we can get other Linux folks to reproduce it.
Other OS's like Windows? If so, I can do that on the other machine (which had the same behavior; my workstation has a tricky setup). It'll take a bit, since I have to prepare a Windows to go flash key and run the cross-compiled executable on it, but I can.
@saveriomiroddi that would be much appreciated. It would help us start to narrow this down and verify that it's a driver / OS issue, rather than a hardware problem.
@saveriomiroddi that would be much appreciated. It would help us start to narrow this down and verify that it's a driver / OS issue, rather than a hardware problem.
So, I've run the program on Windows 10 x64, on one of the two machines that segfaults when running it on Linux, and it didn't segfault. I'm not 100% sure how a hypothetical segfault would be, but I didn't see anything aside the panic in the console (and a window flashing for a very brief moment).
In case this is not clear for others hitting this bug, or what appears to be it at first if a search for the error message led you on this bug, the bug here is I think about the segfault instead of panic, not about the code being wrong in the first place. But it's nonetheless very easy to write wrong code due to add_state() being a bit of a misnomer in my opinion (arguable, I agree). So posting the correct code in case anyone looks for the error message and finds this bug. This doesn't fix the bug but works around it:
Only call add_state() once.
I was hitting the same thing, yet the official examples work. Looking carefully, all 4 examples using state call add_state() once and once only, whereas this bug and my use are both calling it twice at least. I believe this is just a misunderstanding of what add_state() is supposed to do, which is probably not add a state but instead set the initial state. Removing the duplicate call in my case fixes the issue. Other states are reached by state transitioning (see state.rs for example).
Note that to confirm I'm hitting the same callstack and error message with a second add_state(), and the error message could do with some more clarity.
Activity
bjorn3 commentedon Jul 13, 2021
What is the stacktrace? Does it reproduce when you only add a single or no states?
64kramsystem commentedon Jul 13, 2021
Happens only when a second state is added. Full stacktrace here:
alice-i-cecile commentedon Jul 15, 2021
I just tried it on Windows 10 (bevy 0.5) and got the same error message with a standard panic.
I wonder why that's getting turned into a segfault instead...
bjorn3 commentedon Jul 15, 2021
I suspect there is either a bug somewhere in wgpu's handling of destroying the vulkan context when unwinding causing UB manifesting as SIGSEGV in this case. Or an ordering issue between destorying the vulkan context by wgpu and the X11/Wayland context in winit caused by bevy.
alice-i-cecile commentedon Jul 15, 2021
Agreed. @saveriomiroddi does this occur without
DefaultPlugins?Does it occur for other panics, such as the one produced by this snippet?
64kramsystem commentedon Jul 15, 2021
So!
DefaultPlugins-> no segfault;DefaultPlugins-> no segfault.Note that this time, I've tested only on one machine (Nvidia).
alice-i-cecile commentedon Jul 16, 2021
Okay sweet, so it's probably a GPU / windowing cleanup issue like @bjorn3 commented. If you happen to have other OS's for the same machine installed that would be great, otherwise we can see if we can get other Linux folks to reproduce it.
bjorn3 commentedon Jul 16, 2021
I believe I have seen this crash in other issues where a panic happened.
64kramsystem commentedon Jul 16, 2021
Other OS's like Windows? If so, I can do that on the other machine (which had the same behavior; my workstation has a tricky setup). It'll take a bit, since I have to prepare a Windows to go flash key and run the cross-compiled executable on it, but I can.
alice-i-cecile commentedon Jul 16, 2021
@saveriomiroddi that would be much appreciated. It would help us start to narrow this down and verify that it's a driver / OS issue, rather than a hardware problem.
64kramsystem commentedon Jul 16, 2021
So, I've run the program on Windows 10 x64, on one of the two machines that segfaults when running it on Linux, and it didn't segfault. I'm not 100% sure how a hypothetical segfault would be, but I didn't see anything aside the panic in the console (and a window flashing for a very brief moment).
djeedai commentedon Oct 2, 2021
In case this is not clear for others hitting this bug, or what appears to be it at first if a search for the error message led you on this bug, the bug here is I think about the segfault instead of panic, not about the code being wrong in the first place. But it's nonetheless very easy to write wrong code due to
add_state()being a bit of a misnomer in my opinion (arguable, I agree). So posting the correct code in case anyone looks for the error message and finds this bug. This doesn't fix the bug but works around it:Only call
add_state()once.I was hitting the same thing, yet the official examples work. Looking carefully, all 4 examples using state call
add_state()once and once only, whereas this bug and my use are both calling it twice at least. I believe this is just a misunderstanding of whatadd_state()is supposed to do, which is probably not add a state but instead set the initial state. Removing the duplicate call in my case fixes the issue. Other states are reached by state transitioning (seestate.rsfor example).Note that to confirm I'm hitting the same callstack and error message with a second
add_state(), and the error message could do with some more clarity.nicopap commentedon Apr 18, 2023
States got fully reworked in #6587 . This is not an issue anymore.