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

Presence of game pad causes segmentation fault (and proposed fix) #694

Closed
jtdaugherty opened this issue Jan 26, 2016 · 2 comments
Closed
Assignees
Labels
bug Bug reports and bugfix pull requests macOS
Milestone

Comments

@jtdaugherty
Copy link

I am experiencing a segmentation fault inside of GLFW version 3.1.2. All that is required to trigger this for me is to:

I believe the problem is that src/cocoa_joystick.m line 280 is not checking for a possible NULL return value from IOHIDDeviceGetProperty. Then NULL is passed to CFStringGetCString which crashes. I've found reports of other applications crashing with this symptom when NULL is passed to that function. When I unplug the game pad, glfwInit() runs successfully.

I'd submit a pull request but I can't test this first since I can't get glfw3 to link on my machine.

For completeness, here is the call stack:

Process 3963 stopped
* thread #1: tid = 0x890a, 0x00007fff8b29587c CoreFoundation`CFStringGetCString + 44, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
    frame #0: 0x00007fff8b29587c CoreFoundation`CFStringGetCString + 44
CoreFoundation`CFStringGetCString:
->  0x7fff8b29587c <+44>: movq   (%r12), %rax
    0x7fff8b295880 <+48>: testq  %rax, %rax
    0x7fff8b295883 <+51>: je     0x7fff8b2958c4            ; <+116>
    0x7fff8b295885 <+53>: leaq   -0x13d4bba4(%rip), %rcx   ; __CFConstantStringClassReferencePtr
(lldb) bt
* thread #1: tid = 0x890a, 0x00007fff8b29587c CoreFoundation`CFStringGetCString + 44, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x00007fff8b29587c CoreFoundation`CFStringGetCString + 44
    frame #1: 0x0000000100011f86 libglfw3.3.dylib`matchCallback + 148
    frame #2: 0x00007fff8a848c21 IOKit`__IOHIDManagerDeviceApplier + 153
    frame #3: 0x00007fff8b2c0372 CoreFoundation`__CFSetApplyFunction_block_invoke + 18
    frame #4: 0x00007fff8b2a4f80 CoreFoundation`CFBasicHashApply + 128
    frame #5: 0x00007fff8b2c030a CoreFoundation`CFSetApplyFunction + 186
    frame #6: 0x00007fff8a849e86 IOKit`__IOHIDManagerInitialEnumCallback + 58
    frame #7: 0x00007fff8b2e15c1 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    frame #8: 0x00007fff8b2d341c CoreFoundation`__CFRunLoopDoSources0 + 556
    frame #9: 0x00007fff8b2d293f CoreFoundation`__CFRunLoopRun + 927
    frame #10: 0x00007fff8b2d2338 CoreFoundation`CFRunLoopRunSpecific + 296
    frame #11: 0x000000010000e63d libglfw3.3.dylib`_glfwPlatformInit + 1287
    frame #12: 0x000000010000bcf2 libglfw3.3.dylib`glfwInit + 42
    frame #13: 0x0000000100002268 t2`main + 2776
    frame #14: 0x00007fff92d2b5ad libdyld.dylib`start + 1
@elmindreda elmindreda added bug Bug reports and bugfix pull requests macOS labels Jan 26, 2016
@elmindreda elmindreda self-assigned this Jan 26, 2016
@elmindreda elmindreda added this to the 3.2 milestone Jan 26, 2016
aaronmjacobs added a commit to aaronmjacobs/glfw that referenced this issue Feb 8, 2016
@elmindreda
Copy link
Member

This should be fixed by #701.

@jtdaugherty
Copy link
Author

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug reports and bugfix pull requests macOS
Projects
None yet
Development

No branches or pull requests

2 participants