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

Segfault and Window Not Appearing on v0.12.0 #10717

Open
nebocco opened this issue Nov 24, 2023 · 9 comments
Open

Segfault and Window Not Appearing on v0.12.0 #10717

nebocco opened this issue Nov 24, 2023 · 9 comments
Labels
A-Rendering Drawing game state to the screen A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior P-Crash A sudden unexpected crash

Comments

@nebocco
Copy link

nebocco commented Nov 24, 2023

Bevy version

0.12.0

[Optional] Relevant system information

  • Rust: 1.74.0
  • OS: Ubuntu 22.04.3 LTS (on Windows 10, WSL2)

What you did

I ran example codes on the release-0.12.0 branch:

cargo run --example sprite --features wayland

What went wrong

The window didn't appear, and the script suddenly encountered a segmentation fault:

% cargo run --example sprite --features wayland                                                        [release-0.12.0]
   Compiling bevy v0.12.0 (/home/user/Rust/bevy)
    Finished dev [unoptimized + debuginfo] target(s) in 14.65s
     Running `target/debug/examples/sprite`
2023-11-24T01:35:57.591011Z  INFO bevy_winit::system: Creating new window "App" (0v0)
2023-11-24T01:35:57.601675Z ERROR sctk_adwaita::config: XDG Settings Portal did not return response in time: timeout: 100ms, key: color-scheme
2023-11-24T01:35:57.878248Z  INFO bevy_render::renderer: AdapterInfo { name: "D3D12 (NVIDIA GeForce GTX 1650)", vendor: 0, device: 0, device_type: Other, driver: "", driver_info: "", backend: Gl }
ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM default
2023-11-24T01:35:58.117300Z  WARN bevy_audio::audio_output: No audio device found.
2023-11-24T01:35:58.231021Z  WARN bevy_pbr::ssao: ScreenSpaceAmbientOcclusionPlugin not loaded. GPU lacks support: TextureFormat::R16Float does not support TextureUsages::STORAGE_BINDING.
2023-11-24T01:35:58.232566Z  INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "Linux 22.04 Ubuntu", kernel: "5.15.133.1-microsoft-standard-WSL2", cpu: "AMD Ryzen 7 5700X 8-Core Processor", core_count: "8", memory: "7.7 GiB" }
zsh: segmentation fault  cargo run --example sprite --features wayland

Additional information

  • apt update && apt upgrade didn't resolve the problem.
  • the release-0.11.3 branch worked well for me (it produced the same errors and warnings, but the window is displayed correctly.):
% cargo run --example sprite --features wayland                                                        [release-0.11.3]
warning: unused doc comment
  --> crates/bevy_pbr/src/light.rs:62:13
   |
62 |             /// Luminous power in lumens
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
63 |             intensity: 800.0, // Roughly a 60W non-halogen incandescent bulb
   |             ---------------- rustdoc does not generate documentation for expression fields
   |
   = help: use `//` for a plain comment
   = note: `#[warn(unused_doc_comments)]` on by default

warning: unused doc comment
   --> crates/bevy_pbr/src/light.rs:130:13
    |
130 |             /// Luminous power in lumens
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
131 |             intensity: 800.0, // Roughly a 60W non-halogen incandescent bulb
    |             ---------------- rustdoc does not generate documentation for expression fields
    |
    = help: use `//` for a plain comment

warning: `bevy_pbr` (lib) generated 2 warnings
    Finished dev [unoptimized + debuginfo] target(s) in 0.14s
     Running `target/debug/examples/sprite`
2023-11-24T01:58:14.404376Z  INFO bevy_winit::system: Creating new window "App" (0v0)
2023-11-24T01:58:14.406863Z ERROR sctk_adwaita::config: XDG Settings Portal did not return response in time: timeout: 100ms, key: color-scheme
ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM default
2023-11-24T01:58:14.619281Z  WARN bevy_audio::audio_output: No audio device found.
2023-11-24T01:58:14.849030Z  INFO bevy_render::renderer: AdapterInfo { name: "D3D12 (NVIDIA GeForce GTX 1650)", vendor: 0, device: 0, device_type: Other, driver: "", driver_info: "", backend: Gl }
2023-11-24T01:58:14.957976Z  WARN bevy_pbr::ssao: ScreenSpaceAmbientOcclusionPlugin not loaded. GPU lacks support: TextureFormat::R16Float does not support TextureUsages::STORAGE_BINDING.
2023-11-24T01:58:14.959516Z  INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "Linux 22.04 Ubuntu", kernel: "5.15.133.1-microsoft-standard-WSL2", cpu: "AMD Ryzen 7 5700X 8-Core Processor", core_count: "8", memory: "7.7 GiB" }
@nebocco nebocco added C-Bug An unexpected or incorrect behavior S-Needs-Triage This issue needs to be labelled labels Nov 24, 2023
@Kanabenki Kanabenki added P-Crash A sudden unexpected crash A-Windowing Platform-agnostic interface layer to run your app in A-Rendering Drawing game state to the screen and removed S-Needs-Triage This issue needs to be labelled labels Nov 24, 2023
@Kanabenki
Copy link
Contributor

Kanabenki commented Nov 24, 2023

Could you run the crashing example(s) with a debugger to get a backtrace of where the segfault happen?

@nebocco
Copy link
Author

nebocco commented Nov 25, 2023

@Kanabenki I'm sorry, I didn't understand what you meant by "debugger." Is there any software available that can perform further backtrace? For now, I'll attach the logs from running 2d_shapes and bloom_2d with RUST_BACKTRACE=full and LogPlugin { level: DEBUG } added. (the letter � in the log seems to be <ESC>.)
2d_shapes.log
bloom_2d.log

@Kanabenki
Copy link
Contributor

Kanabenki commented Nov 25, 2023

When the process crashes with a segfault, you cannot get a proper backtrace since your process is killed instantly and the code inserted by rustc to handle printing the backtrace on panic does not get a chance to run. By running the process through a debugger, you can capture that backtrace when the crash occurs and see what caused it 🙂

Here's how you can do it:

  1. In your WSL2 shell, start your bevy app (built in debug mode/with debug symbols) through gdb (I don't know if it's installed by default in your WSL2 distribution but you can get it from apt in any case): gdb -ex run --args target/debug/<bevy_app>
  2. Wait for your program to crash, the gdb shell should appear when it happens.
  3. Enter the command bt to get the backtrace. You should get the backtrace for the thread where the segfault occured.

Note that gdb should work properly for just displaying a backtrace, but if you want support for printing/parsing Rust expressions you should use rust-gdb or rust-lldb instead (I think those wrappers are already provided if you installed rust through rustup?).

@nebocco
Copy link
Author

nebocco commented Nov 26, 2023

Thank you very much for explaining it so kindly! I tried running rust-gdb as you instructed, and it turns out there's an error with libnvwgf2umx.so. It seems that there are others experiencing similar symptoms (microsoft/wslg#715). It might be a bug with WSLg, perhaps.

~/bevy % rust-gdb ./target/debug/examples/2d_shapes
GNU gdb (Ubuntu 12.1-0ubuntu1~22.04) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./target/debug/examples/2d_shapes...
(gdb) r
Starting program: /home/user/bevy/target/debug/examples/2d_shapes
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff7b4c640 (LWP 140)]
[New Thread 0x7ffff794b640 (LWP 141)]
[New Thread 0x7ffff774a640 (LWP 142)]
[New Thread 0x7ffff7549640 (LWP 143)]
[New Thread 0x7ffff7345640 (LWP 144)]
[New Thread 0x7ffff7141640 (LWP 145)]
[New Thread 0x7ffff6f3d640 (LWP 146)]
[New Thread 0x7ffff6d39640 (LWP 147)]
[New Thread 0x7ffff6b35640 (LWP 148)]
[New Thread 0x7ffff6931640 (LWP 149)]
[New Thread 0x7ffff672d640 (LWP 150)]
[New Thread 0x7ffff6529640 (LWP 151)]
[New Thread 0x7ffff6325640 (LWP 152)]
[New Thread 0x7ffff6121640 (LWP 153)]
[New Thread 0x7ffff5f1d640 (LWP 154)]
[New Thread 0x7ffff5d19640 (LWP 155)]
2023-11-26T05:33:18.045890Z  INFO bevy_winit::system: Creating new window "App" (0v0)
[Detaching after vfork from child process 156]
2023-11-26T05:33:18.050168Z ERROR sctk_adwaita::config: XDG Settings Portal did not return response in time: timeout: 100ms, key: color-scheme
[Detaching after vfork from child process 162]
[Detaching after vfork from child process 165]
[Detaching after vfork from child process 166]
[New Thread 0x7fffa1a30640 (LWP 168)]
[New Thread 0x7fffa0d1f640 (LWP 169)]
[New Thread 0x7fff9bfff640 (LWP 170)]
[New Thread 0x7fff9b7fe640 (LWP 171)]
[New Thread 0x7fff9affd640 (LWP 172)]
[New Thread 0x7fff99b1c640 (LWP 173)]
[New Thread 0x7fff93fff640 (LWP 174)]
[Thread 0x7fff99b1c640 (LWP 173) exited]
2023-11-26T05:33:18.469523Z  INFO bevy_render::renderer: AdapterInfo { name: "D3D12 (NVIDIA GeForce GTX 1650)", vendor: 0, device: 0, device_type: Other, driver: "", driver_info: "", backend: Gl }
ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM default
2023-11-26T05:33:18.749445Z  WARN bevy_audio::audio_output: No audio device found.
[New Thread 0x7fff99b1c640 (LWP 175)]
[New Thread 0x7fffa051b640 (LWP 176)]
2023-11-26T05:33:18.864504Z  WARN bevy_pbr::ssao: ScreenSpaceAmbientOcclusionPlugin not loaded. GPU lacks support: TextureFormat::R16Float does not support TextureUsages::STORAGE_BINDING.
[New Thread 0x7fff9a6fc640 (LWP 177)]
2023-11-26T05:33:18.867065Z  INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "Linux 22.04 Ubuntu", kernel: "5.15.133.1-microsoft-standard-WSL2", cpu: "AMD Ryzen 7 5700X 8-Core Processor", core_count: "8", memory: "7.7 GiB" }
[Thread 0x7fff93fff640 (LWP 174) exited]

Thread 18 "2d_shapes" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7fffa1a30640 (LWP 168)]
0x00007fffa47cf7e6 in ?? () from /usr/lib/wsl/drivers/nv_dispi.inf_amd64_5b6e4554b945d508/libnvwgf2umx.so


(gdb) bt
#0  0x00007fffa47cf7e6 in ?? () from /usr/lib/wsl/drivers/nv_dispi.inf_amd64_5b6e4554b945d508/libnvwgf2umx.so
#1  0x00007fffa47ce40e in ?? () from /usr/lib/wsl/drivers/nv_dispi.inf_amd64_5b6e4554b945d508/libnvwgf2umx.so
#2  0x00007fffa47ce386 in ?? () from /usr/lib/wsl/drivers/nv_dispi.inf_amd64_5b6e4554b945d508/libnvwgf2umx.so
#3  0x00007ffff7be6ac3 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
#4  0x00007ffff7c78a40 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

@Kanabenki
Copy link
Contributor

Indeed, it seems the problem might come from your execution environment rather than bevy itself. Could you provide the rest of the capture, just to see from where the offending lib is called from bevy?

@nebocco
Copy link
Author

nebocco commented Nov 28, 2023

Actually, this is the entire log. I was expecting to see some Bevy stuff displayed at the end of the backtrace, but nothing else was shown beyond this point.

Addendum: I tried updating to Windows 11, but the situation did not improve. On the contrary, now it seems that nothing is left in the backtrace.

% rust-gdb ./target/debug/examples/2d_shapes                                                           [release-0.12.0]
GNU gdb (Ubuntu 12.1-0ubuntu1~22.04) 12.1
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./target/debug/examples/2d_shapes...
(gdb) r
Starting program: /home/user/bevy/target/debug/examples/2d_shapes
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7ffff7b4b640 (LWP 166)]
[New Thread 0x7fffeffff640 (LWP 167)]
[New Thread 0x7ffff794a640 (LWP 168)]
[New Thread 0x7ffff7749640 (LWP 169)]
[New Thread 0x7ffff7545640 (LWP 170)]
[New Thread 0x7ffff7341640 (LWP 171)]
[New Thread 0x7ffff713d640 (LWP 172)]
[New Thread 0x7ffff6f39640 (LWP 173)]
[New Thread 0x7ffff6d35640 (LWP 174)]
[New Thread 0x7ffff6b31640 (LWP 175)]
[New Thread 0x7ffff692d640 (LWP 176)]
[New Thread 0x7ffff6729640 (LWP 177)]
[New Thread 0x7ffff6525640 (LWP 178)]
[New Thread 0x7ffff6321640 (LWP 179)]
[New Thread 0x7ffff611d640 (LWP 180)]
[New Thread 0x7ffff5f19640 (LWP 181)]
2023-11-28T02:37:36.539039Z  INFO bevy_winit::system: Creating new window "App" (0v0)
[Detaching after vfork from child process 182]
[Detaching after vfork from child process 227]
[Detaching after vfork from child process 230]
[Detaching after vfork from child process 231]
[New Thread 0x7fffa21e0640 (LWP 233)]
[New Thread 0x7fffa19df640 (LWP 234)]
[New Thread 0x7fffa11de640 (LWP 235)]
[New Thread 0x7fffa09dd640 (LWP 236)]
[New Thread 0x7fff9f17c640 (LWP 237)]
[New Thread 0x7fff9e321640 (LWP 238)]
[New Thread 0x7fff9db20640 (LWP 239)]
[New Thread 0x7fff9d31f640 (LWP 240)]
[New Thread 0x7fff9cb1e640 (LWP 241)]
[New Thread 0x7fff970bf640 (LWP 242)]
[Thread 0x7fff9f17c640 (LWP 237) exited]
[Thread 0x7fffa09dd640 (LWP 236) exited]
[Thread 0x7fffa11de640 (LWP 235) exited]
[Thread 0x7fffa19df640 (LWP 234) exited]
[Thread 0x7fffa21e0640 (LWP 233) exited]
2023-11-28T02:37:37.200599Z  INFO bevy_render::renderer: AdapterInfo { name: "D3D12 (NVIDIA GeForce GTX 1650)", vendor: 0, device: 0, device_type: Other, driver: "", driver_info: "", backend: Gl }
ALSA lib confmisc.c:855:(parse_card) cannot find card '0'
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_card_inum returned error: No such file or directory
ALSA lib confmisc.c:422:(snd_func_concat) error evaluating strings
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_concat returned error: No such file or directory
ALSA lib confmisc.c:1334:(snd_func_refer) error evaluating name
ALSA lib conf.c:5178:(_snd_config_evaluate) function snd_func_refer returned error: No such file or directory
ALSA lib conf.c:5701:(snd_config_expand) Evaluate error: No such file or directory
ALSA lib pcm.c:2664:(snd_pcm_open_noupdate) Unknown PCM default
2023-11-28T02:37:37.437372Z  WARN bevy_audio::audio_output: No audio device found.
[New Thread 0x7fffa09dd640 (LWP 243)]
[New Thread 0x7fffa11de640 (LWP 244)]
2023-11-28T02:37:37.550437Z  WARN bevy_pbr::ssao: ScreenSpaceAmbientOcclusionPlugin not loaded. GPU lacks support: TextureFormat::R16Float does not support TextureUsages::STORAGE_BINDING.
[New Thread 0x7fffa19df640 (LWP 245)]
2023-11-28T02:37:37.552017Z  INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "Linux 22.04 Ubuntu", kernel: "5.15.133.1-microsoft-standard-WSL2", cpu: "AMD Ryzen 7 5700X 8-Core Processor", core_count: "8", memory: "7.7 GiB" }
[Thread 0x7fff970bf640 (LWP 242) exited]
[Thread 0x7fffa19df640 (LWP 245) exited]
[Thread 0x7fffa11de640 (LWP 244) exited]
[Thread 0x7fffa09dd640 (LWP 243) exited]
[Thread 0x7fff9cb1e640 (LWP 241) exited]
[Thread 0x7fff9d31f640 (LWP 240) exited]
[Thread 0x7fff9db20640 (LWP 239) exited]
[Thread 0x7fff9e321640 (LWP 238) exited]
[Thread 0x7ffff611d640 (LWP 180) exited]
[Thread 0x7ffff6321640 (LWP 179) exited]
[Thread 0x7ffff6525640 (LWP 178) exited]
[Thread 0x7ffff6729640 (LWP 177) exited]
[Thread 0x7ffff692d640 (LWP 176) exited]
[Thread 0x7ffff6b31640 (LWP 175) exited]
[Thread 0x7ffff6d35640 (LWP 174) exited]
[Thread 0x7ffff6f39640 (LWP 173) exited]
[Thread 0x7ffff713d640 (LWP 172) exited]
[Thread 0x7ffff7341640 (LWP 171) exited]
[Thread 0x7ffff7545640 (LWP 170) exited]
[Thread 0x7ffff7749640 (LWP 169) exited]
[Thread 0x7ffff794a640 (LWP 168) exited]
[Thread 0x7fffeffff640 (LWP 167) exited]
[Thread 0x7ffff7b4b640 (LWP 166) exited]
[Thread 0x7ffff7b4ca40 (LWP 163) exited]
[Thread 0x7ffff5f19640 (LWP 181) exited]
[New process 163]
[Inferior 1 (process 163) exited with code 0150]
(gdb) bt
No stack.
(gdb)

@Kanabenki
Copy link
Contributor

I'm afraid I can't help much more. By any chance have you tried updating your WSL install to pre-release (wsl --update --pre-release) as some people in the issue you linked reported that fixed the problem for them?

@nebocco
Copy link
Author

nebocco commented Nov 29, 2023

Before trying all of these, I had already updated to the pre-release version (I'll attach the logs, though it's in Japanese). I'll wait until there's progress on the issue which I mentioned above, or until someone with the same case finds this issue. Thank you very much for patiently providing me with various instructions!

PS C:\home> wsl --update --pre-release
更新プログラムを確認しています。
Linux 用 Windows サブシステムの最新バージョンは既にインストールされています。

PS C:\home> wsl --version
WSL バージョン: 2.0.11.0
カーネル バージョン: 5.15.133.1-1
WSLg バージョン: 1.0.59
MSRDC バージョン: 1.2.4677
Direct3D バージョン: 1.611.1-81528511
DXCore バージョン: 10.0.25131.1002-220531-1700.rs-onecore-base2-hyp
Windows バージョン: 10.0.22631.2715

@nebocco
Copy link
Author

nebocco commented Nov 30, 2023

I tried running version 0.12.1 and the window showed up but ...... what the heck!?

IMG_3480.MOV

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen A-Windowing Platform-agnostic interface layer to run your app in C-Bug An unexpected or incorrect behavior P-Crash A sudden unexpected crash
Projects
None yet
Development

No branches or pull requests

2 participants