Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: IsKeyPressed Segfault  (Read 2898 times)

0 Members and 1 Guest are viewing this topic.

msteele

  • Newbie
  • *
  • Posts: 12
    • View Profile
IsKeyPressed Segfault
« on: November 24, 2011, 08:10:57 pm »
Hello. I am just venturing into using SFML's network layer, but this problem is unrelated. Any call to sf::Keyboard::IsKeyPressed() causes a segfault. This started happening by itself, no code changes between when it was working and when it started segfaulting. I just recently installed SFML2 from github, but it did work with the new build for a while.

SFML2, just built from github
OS X 10.6.8

Quote
(gdb) run
[a bunch of the usual "Could not find object file" for seemingly unrelated things]

.++++++................................................................................................ done
DEBUG: a
Reading symbols for shared libraries . done

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000081000118
0x00007fff848944b7 in IOHIDDeviceGetValue ()
(gdb) backtrace
#0  0x00007fff848944b7 in IOHIDDeviceGetValue ()
#1  0x00000001000292e6 in sf::priv::HIDInputManager::IsKeyPressed ()
#2  0x0000000100027d7a in sf::priv::InputImpl::IsKeyPressed ()
#3  0x0000000100024589 in sf::Keyboard::IsKeyPressed ()
#4  0x0000000100001719 in main ()
(gdb)

Below is simpler code that fails for me in the same way.

Code: [Select]
#include <iostream>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>

int main (int argc, char **argv) {
  std::cout << "DEBUG: a" << "\n";
  sf::Keyboard::IsKeyPressed(sf::Keyboard::A);
  std::cout << "DEBUG: b" << "\n";
}


Any ideas?

Thanks,
- Miles

sbroadfoot90

  • Jr. Member
  • **
  • Posts: 77
    • View Profile
IsKeyPressed Segfault
« Reply #1 on: November 24, 2011, 10:45:23 pm »
put OS X in the subject.

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
IsKeyPressed Segfault
« Reply #2 on: November 25, 2011, 04:00:45 pm »
runs fine on my computer.

make sure you don't have two different versions (headers/binaries) of SFML installed on your mac.

Quote
[a bunch of the usual "Could not find object file" for seemingly unrelated things]

These only appears when creating a "classic" application with the templates. If you create an application bundle you won't have any issue.

PS : as sbroadfoot90 said, putting OS X in the title helps me tracking the relevant messages on the forum.
SFML / OS X developer

tylerstreeter

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Re: IsKeyPressed Segfault
« Reply #3 on: January 22, 2013, 03:05:01 pm »
I just had the same problem. I'm using OS X with SFML 2.0. There are definitely no other versions of SFML on my machine (I have only installed one version). My app was running fine and then, with no changes to the code, it started crashing in sf::Keyboard::IsKeyPressed().

One possible clue: I'm using the Apple wireless keyboard, and my batteries are getting low. I received a low battery warning around the time that this problem started happening. So I turned off the keyboard and installed new batteries. The problem remained, so I logged out and back in, and the problem was fixed.

So I'm not sure what the problem was exactly (batteries or something else), but there seems to be something keyboard-related that is reset when logging out and back in.