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

Seg Fault when calling root.set_fullscreen on MacOS Mojave #268

Open
tytrdev opened this issue Oct 17, 2018 · 6 comments
Open

Seg Fault when calling root.set_fullscreen on MacOS Mojave #268

tytrdev opened this issue Oct 17, 2018 · 6 comments
Labels

Comments

@tytrdev
Copy link

tytrdev commented Oct 17, 2018

Following the roguelike tutorial I ended up with this function to handle key presses.

Alt + Enter should toggle the screen between fullscreen and the configured window size.
However, when I call root.set_fullscreen I am getting a Segmentation Fault without much other output as to what the exact error could be.

Here is the code:

fn handle_keys(root: &mut Root, x: &mut i32, y: &mut i32) -> bool {
  let key = root.wait_for_keypress(true);
  
  match key {
    // movement keys
    Key { code: Up, .. } => *y -= 1,
    Key { code: Down, .. } => *y += 1,
    Key { code: Left, .. } => *x -= 1,
    Key { code: Right, .. } => *x += 1,
    Key { code: Enter, alt: true, .. } => {
      // Alt+Enter: toggle fullscreen
      let fullscreen = root.is_fullscreen();
      println!("{}", fullscreen);
      root.set_fullscreen(!fullscreen);
    }
    Key { code: Escape, .. } => return true,  // exit game
    _ => {},
  }

  return false;
}

On a side note, I think I will be leaving the mac world for good pretty soon.

@jneumann
Copy link

jneumann commented Oct 25, 2018

I also ran into this on Sierra (10.12.6). I'm not sure what other information you need to help you debug the issue.

@rokob
Copy link

rokob commented Nov 12, 2018

Here is the stacktrace:

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libtcod.dylib                 	0x0000000104a4673b find_resolution + 459 (sys_sdl_c.c:452)
1   libtcod.dylib                 	0x0000000104a43e1c TCOD_sys_set_fullscreen + 60 (sys_sdl_c.c:1240)
2   libtcod.dylib                 	0x0000000104a1406a TCOD_console_set_fullscreen + 90 (console_c.c:137)
3   roguelike                     	0x0000000104966651 tcod::console::Root::set_fullscreen::h489e87843682dd90 + 33 (console.rs:233)
4   roguelike                     	0x0000000104960a47 roguelike::handle_keys::hb6865f503e2e50f5 + 215 (main.rs:111)
5   roguelike                     	0x00000001049608c3 roguelike::main::h788343338086fc09 + 1379 (main.rs:99)
6   roguelike                     	0x000000010495fec2 std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::hc0f517b52b1fe0ff + 18 (rt.rs:74)
7   roguelike                     	0x0000000104973078 std::panicking::try::do_call::hcfe6ac53944e0624 + 24 (panicking.rs:310)
8   roguelike                     	0x000000010497f7ff __rust_maybe_catch_panic + 31 (lib.rs:111)
9   roguelike                     	0x000000010496ee9d std::rt::lang_start_internal::hb972e1f76be57958 + 237 (panicking.rs:294)
10  roguelike                     	0x000000010495fea2 std::rt::lang_start::he93384e8863926d4 + 66 (rt.rs:74)
11  roguelike                     	0x0000000104960ac2 main + 34
12  libdyld.dylib                 	0x00007fff53d88015 start + 1

@rokob
Copy link

rokob commented Nov 12, 2018

Probably because I am using the GLSL renderer and not SDL so the sdl deref in find_resolution is the seg fault.

@rokob
Copy link

rokob commented Nov 12, 2018

Yeah changing back to the default SDL renderer fixes it, but brings back the issue of having a blank screen until hitting a key including when going to fullscreen and back.

@L3nn0x
Copy link
Collaborator

L3nn0x commented Nov 14, 2018

Looks like it's coming from libtcod and not us. Moving to the latest version might help with it. I'll try looking into it when I have time.It could also be Mojave. As they broke quite a few OpenGL things with their latest release, that might be included in it.
It could also be Mojave. As they broke quite a few OpenGL things with their latest release, that might be included in it. If that's the problem, I recommend either changing OS or not using OpenGL until Apple or SDL fixes it.

@L3nn0x L3nn0x added the bug label Nov 14, 2018
@glfmn
Copy link

glfmn commented Jan 11, 2019

I was having a similar issue on

Linux tpy12 4.15.0-43-generic #46-Ubuntu SMP Thu Dec 6 14:45:28 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

After entering fullscreen, I would have to manually kill the process from another TTY to regain control.

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

No branches or pull requests

5 participants