| Summary: | Use of digital pad of a DualShock(in analog mode) crash SDL Application | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Shad <shadow.w> |
| Component: | joystick | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | critical | ||
| Priority: | P2 | CC: | bombasticbryan, twilightinzero |
| Version: | 1.2.13 | ||
| Hardware: | x86 | ||
| OS: | Linux | ||
|
Description
Shad
2008-04-23 02:14:14 UTC
Can you run your program under gdb to get a stack trace? 9/23 10:55 am - Email sent to shadow.w@gmail.com requesting reply to Sam's query. here is what I got using mupen64plus: [shad@azrael ~]$ gdb mupen64plus GNU gdb 6.8-7mdv2010.0 (Mandriva Linux release 2010.0) Copyright (C) 2008 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-mandriva-linux-gnu"... (gdb) run Starting program: /usr/bin/mupen64plus [Thread debugging using libthread_db enabled] [New Thread 0x7f5ef0154750 (LWP 8779)] __ __ __ _ _ ____ _ | \/ |_ _ _ __ ___ _ __ / /_ | || | | _ \| |_ _ ___ | |\/| | | | | '_ \ / _ \ '_ \| '_ \| || |_| |_) | | | | / __| | | | | |_| | |_) | __/ | | | (_) |__ _| __/| | |_| \__ \ |_| |_|\__,_| .__/ \___|_| |_|\___/ |_| |_| |_|\__,_|___/ |_| http://code.google.com/p/mupen64plus/ Version 1.5-development Config Dir: /home/shad/.mupen64plus/ Install Dir: /usr/share/mupen64plus/ Plugin Dir: /usr/share/mupen64plus/plugins/ [New Thread 0x7f5ed834a910 (LWP 8790)] Rescanning rom cache. Scanning... /mnt/emulation/Nintendo/N64/roms/ Rom cache up to date. 335 ROMs. Detaching after fork from child process 8791. [New Thread 0x7f5ed7874910 (LWP 8796)] --------- Here I open the input configuration dialog then press a direction on the digital pad --------- Program received signal SIGSEGV, Segmentation fault. [Switching to Thread 0x7f5ed7874910 (LWP 8796)] 0x00007f5eef37e2dc in EV_HandleEvents (joystick=0x4ae0c10) at src/joystick/linux/SDL_sysjoystick.c:945 945 hats = SDL_joylist[stick->index].map->hatmap+hat; (gdb) bt #0 0x00007f5eef37e2dc in EV_HandleEvents (joystick=0x4ae0c10) at src/joystick/linux/SDL_sysjoystick.c:945 #1 0x00007f5eef37f2c7 in SDL_SYS_JoystickUpdate (joystick=0x0) at src/joystick/linux/SDL_sysjoystick.c:1141 #2 0x00007f5eef34c09d in SDL_JoystickUpdate () at src/joystick/SDL_joystick.c:540 #3 0x00007f5ee5c1e8ca in ?? () from /usr/share/mupen64plus/plugins/blight_input.so #4 0x00007f5eef325415 in SDL_RunThread (data=0x4b0a040) at src/thread/SDL_thread.c:202 #5 0x00007f5eef37d819 in RunThread (data=0x0) at src/thread/pthread/SDL_systhread.c:47 #6 0x00007f5eebef37cd in start_thread () from /lib64/libpthread.so.0 #7 0x00007f5eebc6637d in clone () from /lib64/libc.so.6 #8 0x0000000000000000 in ?? () What are stick->index and SDL_joylist[stick->index].map ? Is there any chance I could borrow the joystick for a few days to test with? Or can I remote log into your system for debugging? (In reply to comment #4) > What are stick->index and SDL_joylist[stick->index].map ? I tried to run GDB with a smaller test program (found here http://www.gnurou.org/writing/linuxmag/sdl/partie2) I've put a breakpoint at line 1001 and 1098 before HandleHat is called and at 921, the beinning of HandleHat [...] Breakpoint 2, EV_HandleEvents (joystick=0x1d2b530) at src/joystick/linux/SDL_sysjoystick.c:1098 1098 code -= ABS_HAT0X; (gdb) print joystick $1 = (SDL_Joystick *) 0xd20450 (gdb) print code $2 = 16 (gdb) print i $3 = 0 (gdb) print events[i].value $4 = -1 (gdb) continue Continuing. Breakpoint 1, EV_HandleEvents (joystick=0xd20450) at src/joystick/linux/SDL_sysjoystick.c:921 921 }; (gdb) print stick No symbol "stick" in current context. (gdb) print joystick $5 = (SDL_Joystick *) 0xd20450 (gdb) continue Continuing. Program received signal SIGSEGV, Segmentation fault. 0x00007fcc5ff892dc in EV_HandleEvents (joystick=0xd20450) at src/joystick/linux/SDL_sysjoystick.c:945 945 hats = SDL_joylist[stick->index].map->hatmap+hat; (gdb) print stick No symbol "stick" in current context. (gdb) bt #0 0x00007fcc5ff892dc in EV_HandleEvents (joystick=0xd20450) at src/joystick/linux/SDL_sysjoystick.c:945 #1 0x00007fcc5ff8a2c7 in SDL_SYS_JoystickUpdate (joystick=0x0) at src/joystick/linux/SDL_sysjoystick.c:1141 #2 0x00007fcc5ff5709d in SDL_JoystickUpdate () at src/joystick/SDL_joystick.c:540 #3 0x00007fcc5ff2d069 in SDL_PollEvent (event=0x0) at src/events/SDL_events.c:393 #4 0x0000000000401187 in process_events () #5 0x0000000000401409 in main () [...] I used gdb a long time ago and I'm not sure to have used it correctly in this case > Is there any chance I could borrow the joystick for a few days to test with? > Or can I remote log into your system for debugging? if you live near paris, France I can bring you the joy and USB adaptor. I prefer not to open this system from the net. In the last test it looks like the source code doesn't correspond to your binary. Can you re-build SDL with -O2 removed from the Makefile CFLAGS, and re-run your test? You should also be able to get the same result from testjoystick, included in the SDL test directory. There's special code to handle those joysticks in SDL, unfortunately I don't have the hardware to test them myself. If you get the same crash, can you then edit src/joystick/linux/SDL_sysjoystick.c and add the following line to the top: #define NO_LOGICAL_JOYSTICKS and rebuild and see what happens? Thanks! *** Bug 786 has been marked as a duplicate of this bug. *** I rebuild SDL with -O0 CLAGS, compiled the testjoystick and run it with gdb, here is what I got: db ./testjoystick GNU gdb 6.8-7mdv2010.0 (Mandriva Linux release 2010.0) Copyright (C) 2008 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-mandriva-linux-gnu"... (gdb) run /dev/input/js0 Starting program: /home/shad/rpm/BUILD/SDL-1.2.13/test/testjoystick /dev/input/js0 [Thread debugging using libthread_db enabled] [New Thread 0x7f057d5956f0 (LWP 31464)] There are 2 joysticks attached Joystick 0: WiseGroup.,Ltd MP-8866 Dual USB Joypad axes: 4 balls: 0 hats: 1 buttons: 12 Joystick 1: WiseGroup.,Ltd MP-8866 Dual USB Joypad axes: 4 balls: 0 hats: 1 buttons: 12 Watching joystick 0: (WiseGroup.,Ltd MP-8866 Dual USB Joypad) Joystick has 4 axes, 1 hats, 0 balls, and 12 buttons Program received signal SIGSEGV, Segmentation fault. 0x00007f057d17ac4b in FindLogicalJoystick (joystick=0x1b999a0, v=0x0) at src/joystick/linux/SDL_sysjoystick.c:850 850 if (SDL_joylist[i].logicalno == v->njoy) { (gdb) bt #0 0x00007f057d17ac4b in FindLogicalJoystick (joystick=0x1b999a0, v=0x0) at src/joystick/linux/SDL_sysjoystick.c:850 #1 0x00007f057d17afbe in HandleHat (stick=0x1b999a0, hat=0 '\0', axis=0, value=0) at src/joystick/linux/SDL_sysjoystick.c:946 #2 0x00007f057d17b741 in EV_HandleEvents (joystick=0x1b999a0) at src/joystick/linux/SDL_sysjoystick.c:1099 #3 0x00007f057d17b937 in SDL_SYS_JoystickUpdate (joystick=0x1b999a0) at src/joystick/linux/SDL_sysjoystick.c:1141 #4 0x00007f057d13ec0f in SDL_JoystickUpdate () at src/joystick/SDL_joystick.c:540 #5 0x00007f057d105b3c in SDL_PumpEvents () at src/events/SDL_events.c:383 #6 0x00007f057d105b4f in SDL_PollEvent (event=0x7fff5cabf110) at src/events/SDL_events.c:393 #7 0x000000000040101b in WatchJoystick () #8 0x0000000000401472 in main () (gdb) print SDL_joylist[i].logicalno $1 = 0 (gdb) print v->njoy Cannot access memory at address 0x0 (gdb) print v $2 = (struct joystick_logical_mapping *) 0x0 (gdb) print i $3 = 0 I tried the adding #define NO_LOGICAL_JOYSTICKS and that did't crashed. [shad@azrael test]$ ./testjoystick /dev/input/js0 There are 2 joysticks attached Joystick 0: WiseGroup.,Ltd MP-8866 Dual USB Joypad axes: 4 balls: 0 hats: 1 buttons: 12 Joystick 1: WiseGroup.,Ltd MP-8866 Dual USB Joypad axes: 4 balls: 0 hats: 1 buttons: 12 Watching joystick 0: (WiseGroup.,Ltd MP-8866 Dual USB Joypad) Joystick has 4 axes, 1 hats, 0 balls, and 12 buttons #### # MOVING THE DIGITAL PAD #### Joystick 0 hat 0 value: left Joystick 0 hat 0 value: centered Joystick 0 hat 0 value: up Joystick 0 hat 0 value: centered Joystick 0 hat 0 value: right Joystick 0 hat 0 value: right down Joystick 0 hat 0 value: down Joystick 0 hat 0 value: centeredJoystick 0 axis 0 value: -1014 #### # MOVING LEFT ANALOG PAD #### Joystick 0 axis 0 value: -4054 Joystick 0 axis 0 value: -6419 Joystick 0 axis 1 value: -9121 Joystick 0 axis 0 value: 0 #### # SWITCHING TO DIGITAL MODE AND MOVING THE DIGITAL PAD #### Joystick 0 axis 0 value: -32768 Joystick 0 axis 0 value: 0 Joystick 0 axis 1 value: -32768 Joystick 0 axis 1 value: 0 Joystick 0 axis 0 value: 32767 Joystick 0 axis 0 value: 0 Joystick 0 axis 1 value: 32767 Compiling with #define NO_LOGICAL_JOYSTICKS also fixes my segfaults. Finally! Thank you very much! :) It looks like newer kernels do the logical device mapping in the driver, so it's no longer necessary (and crashes) in SDL. I'm curious on what kernels the logical mapping code is necessary, and why it's currently crashing, so if anyone has one of these joysticks I can borrow or let me log in to remote debug, please let me know! |