10000 Assert when running on Windows ARM64 · Issue #790 · imgui-rs/imgui-rs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Assert when running on Windows ARM64 #790

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

Open
robmikh opened this issue Sep 12, 2024 · 6 comments
Open

Assert when running on Windows ARM64 #790

robmikh opened this issue Sep 12, 2024 · 6 comments

Comments

@robmikh
Copy link
robmikh commented Sep 12, 2024

Describe the bug
When setting the position of a window, the following assert is hit in imgui:

Assertion failed: cond == 0 || ImIsPowerOfTwo(cond), file C:\Users\person\.cargo\registry\src\index.crates.io-6f17d22bba15001f\imgui-sys-0.12.0\./third-party/imgui-master/imgui/imgui.cpp, line 7287
error: process didn't exit successfully: `target\debug\imguiarm64repro.exe` (exit code: 0xc0000409, STATUS_STACK_BUFFER_OVERRUN)

Here's the stack:

0:000> k
 # Child-SP          RetAddr               Call Site
00 000000e2`0112df40 00007ffc`d5e7d998     ucrtbase!abort+0x3c
01 000000e2`0112df60 00007ffc`d5e7d88c     ucrtbase!common_assert_to_stderr_direct+0xb0
02 000000e2`0112e420 00007ffc`d5e7cef0     ucrtbase!common_assert_to_stderr<wchar_t>+0x24
03 000000e2`0112e450 00007ffc`d5e7da1c     ucrtbase!common_assert<wchar_t>+0xe8
04 000000e2`0112e910 00007ff7`3cf3ed0c     ucrtbase!wassert+0x1c
05 000000e2`0112e920 00007ff7`3cfe638c     imguiarm64repro!ImGui::SetNextWindowPos+0x64 [C:\Users\person\.cargo\registry\src\index.crates.io-6f17d22bba15001f\imgui-sys-0.12.0\third-party\imgui-master\imgui\imgui.cpp @ 7287] 
06 000000e2`0112e960 00007ff7`3c32f5a4     imguiarm64repro!igSetNextWindowPos+0x24 [C:\Users\person\.cargo\registry\src\index.crates.io-6f17d22bba15001f\imgui-sys-0.12.0\third-party\imgui-master\cimgui.cpp @ 195] 
07 000000e2`0112e990 00007ff7`3c32f9a0     imguiarm64repro!imgui::window::Window<ref$<str$> >::begin<ref$<str$> >+0x124 [C:\Users\person\.cargo\registry\src\index.crates.io-6f17d22bba15001f\imgui-0.12.0\src\window\mod.rs @ 504] 
08 000000e2`0112eb00 00007ff7`3c321ea4     imguiarm64repro!imgui::window::Window<ref$<str$> >::build<ref$<str$>,tuple$<>,imguiarm64repro::main::closure_env$0>+0x30 [C:\Users\person\.cargo\registry\src\index.crates.io-6f17d22bba15001f\imgui-0.12.0\src\window\mod.rs @ 559] 
09 000000e2`0112eb40 00007ff7`3c32cb7c     imguiarm64repro!imguiarm64repro::main+0xb70 [C:\Users\person\source\repos\imguiarm64repro\src\main.rs @ 91] 
0a 000000e2`0112fdf0 00007ff7`3c332c70     imguiarm64repro!core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >+0x10 [/rustc/eeb90cda1969383f56a2637cbd3037bdf598841c\library\core\src\ops\function.rs @ 250] 
0b 000000e2`0112fe10 00007ff7`3c332d70     imguiarm64repro!std::sys::backtrace::__rust_begin_short_backtrace<void (*)(),tuple$<> >+0x14 [/rustc/eeb90cda1969383f56a2637cbd3037bdf598841c\library\std\src\sys\backtrace.rs @ 155] 
0c 000000e2`0112fe30 00007ff7`3cf09c00     imguiarm64repro!std::rt::lang_start::closure$0<tuple$<> >+0x18 [/rustc/eeb90cda1969383f56a2637cbd3037bdf598841c\library\std\src\rt.rs @ 162] 
0d (Inline Function) --------`--------     imguiarm64repro!std::rt::lang_start_internal::closure$2+0xc [/rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\std\src\rt.rs @ 141] 
0e (Inline Function) --------`--------     imguiarm64repro!std::panicking::try::do_call+0xc [/rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\std\src\panicking.rs @ 557] 
0f (Inline Function) --------`--------     imguiarm64repro!std::panicking::try+0xc [/rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\std\src\panicking.rs @ 521] 
10 (Inline Function) --------`--------     imguiarm64repro!std::panic::catch_unwind+0xc [/rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\std\src\panic.rs @ 350] 
11 000000e2`0112fe60 00007ff7`3c332d40     imguiarm64repro!std::rt::lang_start_internal+0x8c [/rustc/eeb90cda1969383f56a2637cbd3037bdf598841c/library\std\src\rt.rs @ 141] 
12 000000e2`0112fef0 00007ff7`3c322240     imguiarm64repro!std::rt::lang_start<tuple$<> >+0x50 [/rustc/eeb90cda1969383f56a2637cbd3037bdf598841c\library\std\src\rt.rs @ 161] 
13 000000e2`0112ff50 00007ff7`3d0139b0     imguiarm64repro!main+0x20
14 (Inline Function) --------`--------     imguiarm64repro!invoke_main+0x24 [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl @ 78] 
15 000000e2`0112ff60 00007ff7`3d013a4c     imguiarm64repro!__scrt_common_main_seh+0x128 [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl @ 288] 
16 (Inline Function) --------`--------     imguiarm64repro!__scrt_common_main+0x8 [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl @ 330] 
17 000000e2`0112ffa0 00007ffc`d6c486f0     imguiarm64repro!mainCRTStartup+0x14 [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp @ 16] 
18 000000e2`0112ffb0 00007ffc`da47ff84     KERNEL32!BaseThreadInitThunk+0x40
19 000000e2`0112ffc0 00000000`00000000     ntdll!RtlUserThreadStart+0x44

In the last Rust frame, the value of pos_cond is 4, but when crossing over to C++ the value becomes some large number. The position also seems wrong when crossing over to C++.

Does not repro on x64.

To Reproduce
I have a repro here: https://github.com/robmikh/imguiarm64repro
Run and then press enter to run the code that will hit the assert. If there's a null renderer to slim down the repro, please let me know.

Please describe your environment

  • imgui-rs version 0.12
  • Windows 11 24H2, but it also repros on another arm64 device running Windows 10
  • rustc 1.81.0 (eeb90cda1 2024-09-04)
@robmikh
Copy link
Author
robmikh commented Sep 14, 2024

I think I have a simpler repro with just imgui-sys v0.12 (can also be found in the sys branch of robmikh/imguiarm64repro):

use imgui_sys::{
    igSetCurrentContext, igSetNextWindowPos, ImGuiCond_FirstUseEver, ImGuiContext, ImVec2,
};

fn main() {
    // Dummy ImGuiContext
    let mut bytes = vec![0u8; 1025];
    let context = bytes.as_mut_ptr() as *mut ImGuiContext;
    unsafe { igSetCurrentContext(context) };

    // When you step through igSetNextWindowPos and follow it to the C++ side, you can
    // see that pos, cond, and pivot have incorrect values. It may or not trigger the
    // assert in ImGui::SetNextWindowPos depending on what cond becomes. On my machine,
    // cond becomes 1025 (seemingly from vec size above) and triggers the assert.
    let pos = ImVec2 { x: 200.0, y: 300.0 };
    let cond = ImGuiCond_FirstUseEver; // 4
    let pivot = ImVec2::zero();
    unsafe { igSetNextWindowPos(pos, cond as i32, pivot) };
}

@robmikh
Copy link
Author
robmikh commented Sep 15, 2024

The more I stare at this, the more I think this isn't an issue with imgui-rs or imgui-sys but rather a lower level issue.

I opened a thread in the Rust user forums here: https://users.rust-lang.org/t/possible-code-generation-issue-on-windows-arm64/117580

@sanbox-irl
Copy link
Member

@robmikh any luck in the exploration?

@robmikh
Copy link
Author
robmikh commented Sep 27, 2024

Unfortunately, no. I decided to continue running x64 builds on my ARM64 machines for the time being, as the project I'm working on is something I do in my free time.

@sanbox-irl
Copy link
Member

Understood! I unfortunately don't have a windows ARM device. I suppose I could try cross compiling but I'm not sure that that wouldn't introduce any other issues

@Hadeweka
Copy link

Just for information, the exact same problem occurs with the programming language Crystal as well (which often uses the same ABI code as Rust) - and also only on ARM64 Windows.

In the end, this actually might be some 5F8F error in the Rust/Crystal ABI code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
0