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

Stack Overflow when running metal_triangle example #3

Open
drhaynes opened this issue Jul 25, 2016 · 0 comments
Open

Stack Overflow when running metal_triangle example #3

drhaynes opened this issue Jul 25, 2016 · 0 comments

Comments

@drhaynes
Copy link

Hi, really excited to see this package. I'm very keen to use Metal from rust.

I'm trying to run the metal_triangle example but am getting a stack overflow.

Steps to reproduce:
$ cargo build
$ cargo run --example metal_triangle

Portion of the stack trace is below:


Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib          0x00007fff95823f06 __pthread_kill + 10
1   libsystem_pthread.dylib         0x00007fff9eb624ec pthread_kill + 90
2   libsystem_c.dylib               0x00007fff8dedd6df abort + 129
3   metal_triangle                  0x0000000102cfee1f std::sys::stack_overflow::imp::signal_handler::hff21ef2a2481da88 + 927
4   libsystem_platform.dylib        0x00007fff8e62052a _sigtramp + 26
5   ???                             000000000000000000 0 + 0
6   metal_triangle                  0x0000000102cf9067 _$LT$alloc..raw_vec..RawVec$LT$T$GT$$GT$::double::h7e0e8594a9522e0c + 39
7   metal_triangle                  0x0000000102cf8f29 std::ffi::c_str::CString::from_vec_unchecked::h3a4067cce1afb752 + 41
8   metal_triangle                  0x0000000102cf832e std::ffi::c_str::CString::_new::heb6c4ccd5b4e425d + 158
9   metal_triangle                  0x0000000102cf225c std::ffi::c_str::{{impl}}::new<&str> + 60 (c_str.rs:205)
10  metal_triangle                  0x0000000102cf2bcf objc::runtime::Class::instance_variable::habf51b4c360b69c4 + 47 (runtime.rs:314)
11  metal_triangle                  0x0000000102cc23a2 objc::runtime::{{impl}}::get_ivar<*mut std::os::raw::c_void> + 66 (runtime.rs:443)
12  metal_triangle                  0x0000000102cc2323 metl::extras::window::{{impl}}::set_delegate::draw_in_mtk_view<metal_triangle::main::MyViewDelegate> + 51 (mod.rs:286)
13  com.apple.MetalKit              0x0000000102df2713 -[MTKView draw] + 319
14  metal_triangle                  0x0000000102cc520e objc::message::{{impl}}::invoke<()> + 46 (mod.rs:120)
15  metal_triangle                  0x0000000102cc514b objc::message::send_unverified<objc::runtime::Object,(),()> + 91 (mod.rs:187)
16  metal_triangle                  0x0000000102cc8195 metl::extras::window::View::draw::hac2173034b271621 + 165 (mod.rs:197)
17  metal_triangle                  0x0000000102cc29bd metal_triangle::main::{{impl}}::draw_into_view + 221 (metal_triangle.rs:12)
18  metal_triangle                  0x0000000102cc234f metl::extras::window::{{impl}}::set_delegate::draw_in_mtk_view<metal_triangle::main::MyViewDelegate> + 95 (mod.rs:284)
19  com.apple.MetalKit              0x0000000102df2713 -[MTKView draw] + 319
20  metal_triangle                  0x0000000102cc520e objc::message::{{impl}}::invoke<()> + 46 (mod.rs:120)
21  metal_triangle                  0x0000000102cc514b objc::message::send_unverified<objc::runtime::Object,(),()> + 91 (mod.rs:187)
22  metal_triangle                  0x0000000102cc8195 metl::extras::window::View::draw::hac2173034b271621 + 165 (mod.rs:197)
23  metal_triangle                  0x0000000102cc29bd metal_triangle::main::{{impl}}::draw_into_view + 221 (metal_triangle.rs:12)
24  metal_triangle                  0x0000000102cc234f metl::extras::window::{{impl}}::set_delegate::draw_in_mtk_view<metal_triangle::main::MyViewDelegate> + 95 (mod.rs:284)
25  com.apple.MetalKit              0x0000000102df2713 -[MTKView draw] + 319
26  metal_triangle                  0x0000000102cc520e objc::message::{{impl}}::invoke<()> + 46 (mod.rs:120)
27  metal_triangle                  0x0000000102cc514b objc::message::send_unverified<objc::runtime::Object,(),()> + 91 (mod.rs:187)
28  metal_triangle                  0x0000000102cc8195 metl::extras::window::View::draw::hac2173034b271621 + 165 (mod.rs:197)
29  metal_triangle                  0x0000000102cc29bd metal_triangle::main::{{impl}}::draw_into_view + 221 (metal_triangle.rs:12)
30  metal_triangle                  0x0000000102cc234f metl::extras::window::{{impl}}::set_delegate::draw_in_mtk_view<metal_triangle::main::MyViewDelegate> + 95 (mod.rs:284)
31  com.apple.MetalKit              0x0000000102df2713 -[MTKView draw] + 319

So it seems the culprit is a recursive call to [MTKView draw]. Indeed, commenting out the view.draw call in the delegate and replacing it with a call to window.view.draw() in the main loop makes the crash stop happening. However, there doesn't appear to be any drawing happening, as the window's view is blank, and not showing a red colour as to be expected from the example code.

I have also tried updating the cocoa crate to latest (0.4.4) but this hasn't made a difference.

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

1 participant