Hello,
I try to support joystick hotplug on Linux through HAL. When a joystick
is plugged or unplugged I receive an HAL message and restart joystick
subsystem.
// Restart SDL joystick subsystem
SDL_QuitSubSystem(SDL_INIT_JOYSTICK);
if (SDL_WasInit(SDL_INIT_JOYSTICK) != 0)
{
printf("HAL: Stop joystick subsystem failed");
return false;
}
if(SDL_InitSubSystem(SDL_INIT_JOYSTICK) != 0)
{
printf("HAL: Restart joystick subsystem failed : %s",SDL_GetError
());
return false;
}
// Initialize joysticks ...
It works with one joystick but failed with 2 when I disconnect the last.
An “double free or corruption (fasttop)” error occurred.
I have also test to close all joysticks before restart subsystem.
gdb backtrace:
SDL-1.2.13
#0 0x000000350fc32f05 in raise (sig=)
at …/nptl/sysdeps/unix/sysv/linux/raise.c:64
#1 0x000000350fc34a73 in abort () at abort.c:88
#2 0x000000350fc72438 in __libc_message (do_abort=2,
fmt=0x350fd3c428 “*** glibc detected *** %s: %s: 0x%s ***\n”)
at …/sysdeps/unix/sysv/linux/libc_fatal.c:170
#3 0x000000350fc77ec8 in malloc_printerr (action=2,
str=0x350fd3c4c8 “double free or corruption (fasttop)”,
ptr=) at malloc.c:5994
#4 0x000000350fc7a486 in __libc_free (mem=0x350fd32880) at malloc.c:3625
#5 0x0000003dd1e3421b in SDL_JoystickQuit ()
at src/joystick/SDL_joystick.c:411
#6 0x0000003dd1e07f85 in SDL_QuitSubSystem (flags=512) at src/SDL.c:184
#7 0x0000000000e29934 in CHalManager::RemoveDevice (this=0x150a660,
udi=0x1a0fe44 “/org/freedesktop/Hal/devices/
usb_device_45e_289_noserial_if0_logicaldev_input”) at HalManager.cpp:686
#8 0x0000000000e29b80 in CHalManager::DeviceRemoved (ctx=0x1b18080,
udi=0x1a0fe44 “/org/freedesktop/Hal/devices/
usb_device_45e_289_noserial_if0_logicaldev_input”) at HalManager.cpp:49
#9 0x00007ffff7866d29 in ?? () from /usr/lib64/libhal.so.1
#10 0x000000350f00ef7b in dbus_connection_dispatch ()
from /lib64/libdbus-1.so.3
#11 0x000000350f00f33b in ?? () from /lib64/libdbus-1.so.3
—Type to continue, or q to quit—
#12 0x0000000000e29d3b in CHalManager::Update (this=0x150a660)
at HalManager.cpp:373
#13 0x0000000000846f14 in CApplication::ProcessSlow (this=0x149c9a0)
at Application.cpp:5125
#14 0x000000000084e617 in CApplication::Process (this=0x149c9a0)
at Application.cpp:5056
#15 0x0000000000b4828b in CXBApplicationEx::Run (this=0x149c9a0)
at XBApplicationEx.cpp:210
#16 0x0000000000b48c26 in main (argc=1, argv=0x7fffffffe338)
at XboxMediaCenter.cpp:117
Do you have any ideas ?