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

librusty_vangers failing inside wgpu:command.rs #190

Closed
caiiiycuk opened this issue Jan 26, 2022 · 13 comments
Closed

librusty_vangers failing inside wgpu:command.rs #190

caiiiycuk opened this issue Jan 26, 2022 · 13 comments

Comments

@caiiiycuk
Copy link
Contributor

I compiled render-ng branch natively, but when I try to run it constantly fails with error:

thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', /home/caiiiycuk/.cargo/git/checkouts/wgpu-53e70f8674b08dd4/f3891fe/wgpu-hal/src/gles/command.rs:82:38
stack backtrace:
   0: rust_begin_unwind
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:517:5
   1: core::panicking::panic_fmt
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/panicking.rs:100:14
   2: core::panicking::panic
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/panicking.rs:50:5
   3: core::option::Option<T>::unwrap
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/option.rs:746:21
   4: wgpu_hal::gles::command::<impl wgpu_hal::gles::CommandEncoder>::rebind_vertex_data
             at /home/caiiiycuk/.cargo/git/checkouts/wgpu-53e70f8674b08dd4/f3891fe/wgpu-hal/src/gles/command.rs:82:26
   5: wgpu_hal::gles::command::<impl wgpu_hal::gles::CommandEncoder>::prepare_draw
             at /home/caiiiycuk/.cargo/git/checkouts/wgpu-53e70f8674b08dd4/f3891fe/wgpu-hal/src/gles/command.rs:142:13
   6: wgpu_hal::gles::command::<impl wgpu_hal::CommandEncoder<wgpu_hal::gles::Api> for wgpu_hal::gles::CommandEncoder>::draw
             at /home/caiiiycuk/.cargo/git/checkouts/wgpu-53e70f8674b08dd4/f3891fe/wgpu-hal/src/gles/command.rs:812:9
   7: wgpu_core::command::render::<impl wgpu_core::hub::Global<G>>::command_encoder_run_render_pass_impl
             at /home/caiiiycuk/.cargo/git/checkouts/wgpu-53e70f8674b08dd4/f3891fe/wgpu-core/src/command/render.rs:1534:29
   8: wgpu_core::command::render::<impl wgpu_core::hub::Global<G>>::command_encoder_run_render_pass
             at /home/caiiiycuk/.cargo/git/checkouts/wgpu-53e70f8674b08dd4/f3891fe/wgpu-core/src/command/render.rs:1018:9
   9: <wgpu::backend::direct::Context as wgpu::Context>::command_encoder_end_render_pass
             at /home/caiiiycuk/.cargo/git/checkouts/wgpu-53e70f8674b08dd4/f3891fe/wgpu/src/backend/direct.rs:2007:13
  10: <wgpu::RenderPass as core::ops::drop::Drop>::drop
             at /home/caiiiycuk/.cargo/git/checkouts/wgpu-53e70f8674b08dd4/f3891fe/wgpu/src/lib.rs:2825:13
  11: core::ptr::drop_in_place<wgpu::RenderPass>
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/ptr/mod.rs:188:1
  12: vangers::render::Render::draw_world
             at /home/caiiiycuk/gamepix/games/vange-rs-em/src/render/mod.rs:761:9
  13: rv_render
             at /home/caiiiycuk/gamepix/games/vange-rs-em/lib/ffi/src/lib.rs:393:5
  14: _ZN8renderer13visualbackend4rust17RustVisualBackend6renderERKNS_4RectE
             at /home/caiiiycuk/gamepix/games/Vangers/render-ng/lib/renderer/src/renderer/visualbackend/rust/RustVisualBackend.cpp:198:2
  15: _ZN8iGameMap4drawEi
             at /home/caiiiycuk/gamepix/games/Vangers/render-ng/src/road.cpp:2077:14
  16: _Z9gameQuantv
             at /home/caiiiycuk/gamepix/games/Vangers/render-ng/src/road.cpp:1988:13
  17: _ZN11LoadingRTO211DelayedInitEv
             at /home/caiiiycuk/gamepix/games/Vangers/render-ng/src/road.cpp:1048:2
  18: _ZN11LoadingRTO25QuantEv
             at /home/caiiiycuk/gamepix/games/Vangers/render-ng/src/road.cpp:1099:13
  19: _Z11normal_loopv
             at /home/caiiiycuk/gamepix/games/Vangers/render-ng/lib/xtool/xtcore.cpp:142:24
  20: _Z12vangers_mainiPPc
             at /home/caiiiycuk/gamepix/games/Vangers/render-ng/lib/xtool/xtcore.cpp:239:8
  21: _ZZ4mainENK3$_0clEiPPc
             at /home/caiiiycuk/gamepix/games/Vangers/gpx/main.cpp:53:20
  22: _ZSt13__invoke_implIiRZ4mainE3$_0JiPPcEET_St14__invoke_otherOT0_DpOT1_
             at /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:61:14
  23: _ZSt10__invoke_rIiRZ4mainE3$_0JiPPcEENSt9enable_ifIXsr6__and_ISt6__not_ISt7is_voidIT_EESt14is_convertibleINSt15__invoke_resultIT0_JDpT1_EE4typeES7_EEE5valueES7_E4typeEOSC_DpOSD_
             at /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:142:14
  24: _ZNSt17_Function_handlerIFiiPPcEZ4mainE3$_0E9_M_invokeERKSt9_Any_dataOiOS1_
             at /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/std_function.h:291:9
  25: _ZNKSt8functionIFiiPPcEEclEiS1_
             at /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/std_function.h:560:9
  26: _ZZN7gamepix3Sys4mainEiPPcRKNS0_11InitOptionsEENK3$_0clEv
             at /home/caiiiycuk/sdk/gpx-toolkit/virtualenv/c/sys.cpp:367:5
  27: _ZSt13__invoke_implIvRZN7gamepix3Sys4mainEiPPcRKNS1_11InitOptionsEE3$_0JEET_St14__invoke_otherOT0_DpOT1_
             at /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:61:14
  28: _ZSt10__invoke_rIvRZN7gamepix3Sys4mainEiPPcRKNS1_11InitOptionsEE3$_0JEENSt9enable_ifIXsr6__and_ISt7is_voidIT_ESt14__is_invocableIT0_JDpT1_EEEE5valueESB_E4typeEOSE_DpOSF_
             at /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/invoke.h:154:7
  29: _ZNSt17_Function_handlerIFvvEZN7gamepix3Sys4mainEiPPcRKNS2_11InitOptionsEE3$_0E9_M_invokeERKSt9_Any_data
             at /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/std_function.h:291:9
  30: _ZNKSt8functionIFvvEEclEv
             at /usr/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/std_function.h:560:9
  31: _storage_sync_done
             at /home/caiiiycuk/sdk/gpx-toolkit/virtualenv/c/storage.cpp:84:14
  32: _ZN7gamepix7Storage4syncESt8functionIFvvEE
             at /home/caiiiycuk/sdk/gpx-toolkit/virtualenv/c/storage.cpp:102:5
  33: _ZN7gamepix3Sys4mainEiPPcRKNS0_11InitOptionsE
             at /home/caiiiycuk/sdk/gpx-toolkit/virtualenv/c/sys.cpp:358:21
  34: main
             at /home/caiiiycuk/gamepix/games/Vangers/gpx/main.cpp:59:19
  35: __libc_start_call_main
             at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
  36: __libc_start_main_impl
             at ./csu/../csu/libc-start.c:409:3
  37: _start
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
fatal runtime error: failed to initiate panic, error 5
Signal: SIGABRT (signal SIGABRT)

Here:

    fn rebind_vertex_data(&mut self, first_instance: u32) {
        if self
            .private_caps
            .contains(super::PrivateCapabilities::VERTEX_BUFFER_LAYOUT)
        {
            for (index, &(ref vb_desc, ref vb)) in self.state.vertex_buffers.iter().enumerate() {
                if self.state.dirty_vbuf_mask & (1 << index) == 0 {
                    continue;
                }
                let vb = vb.as_ref().unwrap(); //** <--- HERE**
                let instance_offset = match vb_desc.step {

GPU:
[2022-01-26T08:22:28Z INFO wgpu_hal::gles::adapter] Vendor: Intel
[2022-01-26T08:22:28Z INFO wgpu_hal::gles::adapter] Renderer: Mesa Intel(R) HD Graphics 620 (KBL GT2)
[2022-01-26T08:22:28Z INFO wgpu_hal::gles::adapter] Version: OpenGL ES 3.2 Mesa 21.2.

Full log
full-log.txt

@kvark
Copy link
Owner

kvark commented Jan 26, 2022

Does vange-rs work for you if you set GL in the config (as "backend: GL")?

@caiiiycuk
Copy link
Contributor Author

Road works fine on GL backend.

@caiiiycuk
Copy link
Contributor Author

I think there is some UB in my build, will look into it tomorrow

@caiiiycuk
Copy link
Contributor Author

Nope valgrind shows that there is no errors

@caiiiycuk
Copy link
Contributor Author

and it works in browser :)

@kvark
Copy link
Owner

kvark commented Jan 27, 2022

Could you reproduce this via https://github.com/lpenguin/rv_ffi ?

@lpenguin
Copy link
Collaborator

lpenguin commented Jan 27, 2022

I can reproduce it in rv_ffi. It fails from the commit 2341f55 (Water: first implementation). I pushed a small fix to it, so you may need a pull.

@caiiiycuk
Copy link
Contributor Author

Yep same here

caiiiycuk@caiiiycuk-ubuntu:~/gamepix/games/Vangers/res_linux$ RUST_BACKTRACE=1 ~/tmp/rv_ffi/build/rv_ffi 
GL version: OpenGL ES 3.2 Mesa 21.2.2
rv_init
rv_map_init
rv_map_update_palette
rv_camera_init
rv_map_update_data
rv_camera_set_transform position=1024 1024 512, rotation=-0.5 -0 -0 0.866025
rv_render
thread '<unnamed>' panicked at 'called `Option::unwrap()` on a `None` value', /home/caiiiycuk/.cargo/git/checkouts/wgpu-53e70f8674b08dd4/77b2c25/wgpu-hal/src/gles/command.rs:98:38
stack backtrace:
   0: rust_begin_unwind
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:517:5
   1: core::panicking::panic_fmt
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/panicking.rs:100:14
   2: core::panicking::panic
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/panicking.rs:50:5
   3: core::option::Option<T>::unwrap
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/option.rs:746:21
   4: wgpu_hal::gles::command::<impl wgpu_hal::gles::CommandEncoder>::rebind_vertex_data
             at /home/caiiiycuk/.cargo/git/checkouts/wgpu-53e70f8674b08dd4/77b2c25/wgpu-hal/src/gles/command.rs:98:26
   5: wgpu_hal::gles::command::<impl wgpu_hal::gles::CommandEncoder>::prepare_draw
             at /home/caiiiycuk/.cargo/git/checkouts/wgpu-53e70f8674b08dd4/77b2c25/wgpu-hal/src/gles/command.rs:158:13
   6: wgpu_hal::gles::command::<impl wgpu_hal::CommandEncoder<wgpu_hal::gles::Api> for wgpu_hal::gles::CommandEncoder>::draw
             at /home/caiiiycuk/.cargo/git/checkouts/wgpu-53e70f8674b08dd4/77b2c25/wgpu-hal/src/gles/command.rs:845:9
   7: wgpu_core::command::render::<impl wgpu_core::hub::Global<G>>::command_encoder_run_render_pass_impl
             at /home/caiiiycuk/.cargo/git/checkouts/wgpu-53e70f8674b08dd4/77b2c25/wgpu-core/src/command/render.rs:1534:29
   8: wgpu_core::command::render::<impl wgpu_core::hub::Global<G>>::command_encoder_run_render_pass
             at /home/caiiiycuk/.cargo/git/checkouts/wgpu-53e70f8674b08dd4/77b2c25/wgpu-core/src/command/render.rs:1018:9
   9: <wgpu::backend::direct::Context as wgpu::Context>::command_encoder_end_render_pass
             at /home/caiiiycuk/.cargo/git/checkouts/wgpu-53e70f8674b08dd4/77b2c25/wgpu/src/backend/direct.rs:2007:13
  10: <wgpu::RenderPass as core::ops::drop::Drop>::drop
             at /home/caiiiycuk/.cargo/git/checkouts/wgpu-53e70f8674b08dd4/77b2c25/wgpu/src/lib.rs:2825:13
  11: core::ptr::drop_in_place<wgpu::RenderPass>
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/ptr/mod.rs:188:1
  12: vangers::render::Render::draw_world
             at /home/caiiiycuk/gamepix/games/vange-rs-em/src/render/mod.rs:761:9
  13: rv_render
             at /home/caiiiycuk/gamepix/games/vange-rs-em/lib/ffi/src/lib.rs:393:5
  14: main
  15: __libc_start_call_main
             at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
  16: __libc_start_main_impl
             at ./csu/../csu/libc-start.c:409:3
  17: _start
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
fatal runtime error: failed to initiate panic, error 5
Аварийный останов (стек памяти сброшен на диск)
caiiiycuk@caiiiycuk-ubuntu:~/gamepix/games/Vangers/res_linux$ 

@caiiiycuk
Copy link
Contributor Author

I can confirm:
950a5dd - works
2341f55 - not working

@kvark
Copy link
Owner

kvark commented Jan 28, 2022

looks like some memory stomping is taking place:

    at /home/kvark/.cargo/git/checkouts/wgpu-53e70f8674b08dd4/77b2c25/wgpu-hal/src/gles/command.rs:98
98                      let vb = vb.as_ref().unwrap();
(gdb) p index
$1 = 1
(gdb) p first_instance
$2 = 0
(gdb) p self.state.vertex_buffers
$3 = [
Aborted (core dumped)

i.e. just printing the state leads to a core dump. This is unusual.

@lpenguin
Copy link
Collaborator

Hm, it could be something from the C++ side also, I'll check it

@kvark
Copy link
Owner

kvark commented Jan 28, 2022

no, it's just my debugger being buggy. The logic bug is in wgpu-hal/gles. Fix is coming!

@kvark
Copy link
Owner

kvark commented Jan 28, 2022

Fixes in 671a10a, which carries gfx-rs/wgpu#2427

@kvark kvark closed this as completed Jan 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants