segfault with two joysticks

segfault with two joysticks

Postby greggler » 19 Dec 2010, 05:06

i am using the sony sixaxis wireless joysticks. connection either one of the two i have works great with STK
however, connecting both at once causes a segfault on startup
supertuxkart[20430]: segfault at 0 ip 080a8f83 sp bf828f00 error 4 in supertuxkart[8048000+20a000]

any advice on what i can i do to gather more info and hunt this down in the code?
greggler
 
Posts: 10
Joined: 19 Dec 2010, 05:03

Re: segfault with two joysticks

Postby hiker » 19 Dec 2010, 11:24

greggler {l Wrote}:any advice on what i can i do to gather more info and hunt this down in the code?

What system are you on? Could you compile your own version, so that we could get some debug information (note that we can not distribute a debug version at least of windows due to restrictions by Microsoft).

Do you see any warnings/messages on stdout (if you are on windows, try starting it from the command line).

Cheers,
Joerg
hiker
 
Posts: 1435
Joined: 07 Dec 2009, 12:15
Location: Melbourne, Australia

Re: segfault with two joysticks

Postby greggler » 19 Dec 2010, 17:59

Hi Joerg, thanks for the quick reply.

Some more detailed info: I am running 32bit Ubuntu 10.10 on an Amd platform. The joysticks are Sony sixaxis which connect via bluetooth. I'm using the qtsixa software to manage them as standard unix joysticks.

If you don't have suitable debug binaries available then I have no problems downloading and compiling. I'll try to get started on that tonight. If you have any specifics on how to test (command line args, etc) please let me know.

Thanks,
Greg
greggler
 
Posts: 10
Joined: 19 Dec 2010, 05:03

Re: segfault with two joysticks

Postby Auria » 19 Dec 2010, 21:56

Invoking in gdb is usually as simple as :

$ gdb supertuxkart
$ run
... make it crash ...
$ bt

then paste the output. You can try already, maybe your build contains sufficient information to help us. Otherwise, making a debug build will be appropriate :)
Image
User avatar
Auria
STK Moderator
 
Posts: 2976
Joined: 07 Dec 2009, 03:52

Re: segfault with two joysticks

Postby hiker » 20 Dec 2010, 00:35

Also add the command line parameter "--v 6" - which will make stk a lot more verbose.

Thanks!
Joerg
hiker
 
Posts: 1435
Joined: 07 Dec 2009, 12:15
Location: Melbourne, Australia

Re: segfault with two joysticks

Postby greggler » 20 Dec 2011, 20:27

been a long time since i've reported this but here is some more info.
- using latest sixad to connect two sixaxis controllers
- using the latest stk 0.7.3 code compiled with debug
- using irrlicht revision 3843

here is the stacktrace:

Program received signal SIGSEGV, Segmentation fault.
0x0000000000497274 in GUIEngine::EventHandler::onGUIEvent (this=0x1bc69f0, event=...) at guiengine/event_handler.cpp:649
649 const s32 id = event.GUIEvent.Caller->getID();
(gdb) bt
#0 0x0000000000497274 in GUIEngine::EventHandler::onGUIEvent (this=0x1bc69f0, event=...) at guiengine/event_handler.cpp:649
#1 0x00000000004977fd in GUIEngine::EventHandler::OnEvent (this=0x1bc69f0, event=...) at guiengine/event_handler.cpp:126
#2 0x000000000064d27f in irr::CIrrDeviceStub::postEventFromUser (this=0xe19e30, event=...) at CIrrDeviceStub.cpp:211
#3 0x0000000000644781 in irr::CIrrDeviceLinux::pollJoysticks (this=0xe19e30) at CIrrDeviceLinux.cpp:1731
#4 0x0000000000640df3 in irr::CIrrDeviceLinux::run (this=0xe19e30) at CIrrDeviceLinux.cpp:1118
#5 0x0000000000469303 in IrrDriver::update (this=0xe0f4e0, dt=0) at graphics/irr_driver.cpp:1212
#6 0x0000000000411894 in MainLoop::run (this=0x20816d0) at main_loop.cpp:156
#7 0x000000000040ee18 in main (argc=<value optimized out>, argv=<value optimized out>) at main.cpp:1309

in specific, at guiengine/event_handler.cpp line 649, event.GUIEvent.Caller is null:
const s32 id = event.GUIEvent.Caller->getID();


any ideas?

thanks,
Greg
greggler
 
Posts: 10
Joined: 19 Dec 2010, 05:03

Re: segfault with two joysticks

Postby Auria » 20 Dec 2011, 21:20

Hi,

thanks for the information

I tried a fix for that in SVN trunk, r10458. Do you think you could try again with this revision.
Image
User avatar
Auria
STK Moderator
 
Posts: 2976
Joined: 07 Dec 2009, 03:52

Re: segfault with two joysticks

Postby greggler » 20 Dec 2011, 22:53

unfortunately, svn trunk doesnt compile at that revision:

In file included from guiengine/widgets/CGUIEditBox.cpp:5:0:
guiengine/widgets/CGUIEditBox.h:39:25: error: conflicting return type specified for ‘virtual irr::video::SColor CGUIEditBox::getOverrideColor() const’
/usr/local/include/IGUIEditBox.h:42:33: error: overriding ‘virtual const irr::video::SColor& irr::gui::IGUIEditBox::getOverrideColor() const’
make[2]: *** [CGUIEditBox.o] Error 1


should i try to overlay your fix onto the 0.7.3 source?
greggler
 
Posts: 10
Joined: 19 Dec 2010, 05:03

Re: segfault with two joysticks

Postby greggler » 20 Dec 2011, 23:30

i copied the fix into the 0.7.3 code and it didnt crash but the game still froze.
after hitting control-c, here is the backtrace:

(gdb) bt
#0 0x00007ffff678b35d in read () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x0000000000644730 in irr::CIrrDeviceLinux::pollJoysticks (this=0xe229c0) at CIrrDeviceLinux.cpp:1707
#2 0x0000000000640df3 in irr::CIrrDeviceLinux::run (this=0xe229c0) at CIrrDeviceLinux.cpp:1118
#3 0x0000000000469303 in IrrDriver::update (this=0xe0f4e0, dt=0.0500000007) at graphics/irr_driver.cpp:1212
#4 0x0000000000411894 in MainLoop::run (this=0x1ffafc0) at main_loop.cpp:156
#5 0x000000000040ee18 in main (argc=<value optimized out>, argv=<value optimized out>) at main.cpp:1309
(gdb) quit
greggler
 
Posts: 10
Joined: 19 Dec 2010, 05:03

Re: segfault with two joysticks

Postby Auria » 21 Dec 2011, 18:17

Hi,

you can use latest SVN of STK, but you will need to upgrade your irrlicht to the latest SVN version

I think it would be better if you did that because in your latest backtrace I see it hanging it "CIrrDeviceLinux::pollJoysticks", which would be inside irrlicht and out of our control - so best try the latest version of everything
Image
User avatar
Auria
STK Moderator
 
Posts: 2976
Joined: 07 Dec 2009, 03:52

Re: segfault with two joysticks

Postby greggler » 22 Dec 2011, 03:57

updated to latest svn for both stk and irrlicht. compiles fine and runs but same problem.
searching on polljoysticks line 1707, i see there is a recent bug report from 2 months ago:
http://sourceforge.net/apps/trac/supert ... ticket/480

an interesting piece of info is about how entering a carriage return in the stk terminal window lets the game run for a bit.
when i hit nonstop carriage returns in the stk terminal window the game actually flows through just fine and i can even (awkwardly) start a race.

so ... somewhere in the midst of joystick polling some piece of code is reading from stdin? could this be an artifact of irrlicht or possibly the sixad joystick driver?
greggler
 
Posts: 10
Joined: 19 Dec 2010, 05:03

Re: segfault with two joysticks

Postby Auria » 22 Dec 2011, 04:12

Ah, checking the code... it would seem that irrlicht reads from joysticks like they were files, from /dev/js or /dev/input/js . It would seem that for some reason in your case opening the /dev/js stream fails and it instead opens stdin somehow.

We can try something. Open the CIrrDeviceLinux.cpp file, and right before line 1707, which is

{l Code}: {l Select All Code}
      while(sizeof(event) == read(info.fd, &event, sizeof(event)))


add another line to make it like :

{l Code}: {l Select All Code}
                printf("info.fd = %i\n", info.fd);
      while(sizeof(event) == read(info.fd, &event, sizeof(event)))


then rebuild irrlicht, rebuild STK, and run STK. I'd be interested by what it prints...
Image
User avatar
Auria
STK Moderator
 
Posts: 2976
Joined: 07 Dec 2009, 03:52

Re: segfault with two joysticks

Postby greggler » 22 Dec 2011, 05:04

tweaked the debug print just a bit:
printf("joystick: %d / %d info.fd = %i\n", j, ActiveJoysticks.size(), info.fd);

looks like the fd is indeed zero for the second joystick. here is the output:
joystick: 0 / 2 info.fd = 12
joystick: 1 / 2 info.fd = 0
greggler
 
Posts: 10
Joined: 19 Dec 2010, 05:03

Re: segfault with two joysticks

Postby greggler » 22 Dec 2011, 05:44

interesting, when i put a debug at line 1634 i see this:
found joystick num:0 fname=/dev/input/js0 fd=12
found joystick num:1 fname=/dev/input/js1 fd=13

he fd on the second joystick is originally 13 but later gets set to zero.
have to get going now but will step through it later and see where that happens.
greggler
 
Posts: 10
Joined: 19 Dec 2010, 05:03

Re: segfault with two joysticks

Postby greggler » 22 Dec 2011, 09:29

i think the problem is inside of the sixad driver and also CirrDeviceLinux.cpp is not being careful
traced it down to line 1720.
info.persistentData.JoystickEvent.Axis[event.number] = event.value;
the event.number must be < NUMBER_OF_AXES which is 6 and the actual value can be in the 20s
so, it was stomping on memory past the end of the array and that is what was zeroing out the fd.

i protected that array index with a check on max safe value and it did resolve the problem with freezing. no more null file descriptor but also no happy working 2 joysticks.
further debugging shows that the buttons presses on the sixaxis are arriving as event type JS_EVENT_AXIS rather than JS_EVENT_BUTTON so i'll see about working with the sixad folks.

thanks for the help though in sending me on the right path
greggler
 
Posts: 10
Joined: 19 Dec 2010, 05:03

Re: segfault with two joysticks

Postby Auria » 22 Dec 2011, 17:54

greggler {l Wrote}:i think the problem is inside of the sixad driver and also CirrDeviceLinux.cpp is not being careful
traced it down to line 1720.
info.persistentData.JoystickEvent.Axis[event.number] = event.value;
the event.number must be < NUMBER_OF_AXES which is 6 and the actual value can be in the 20s
so, it was stomping on memory past the end of the array and that is what was zeroing out the fd.

i protected that array index with a check on max safe value and it did resolve the problem with freezing. no more null file descriptor but also no happy working 2 joysticks.
further debugging shows that the buttons presses on the sixaxis are arriving as event type JS_EVENT_AXIS rather than JS_EVENT_BUTTON so i'll see about working with the sixad folks.

thanks for the help though in sending me on the right path


thanks a lot for debugging this!! Did you submit this information to the irrlicht developers? If no I will do so
Image
User avatar
Auria
STK Moderator
 
Posts: 2976
Joined: 07 Dec 2009, 03:52

Re: segfault with two joysticks

Postby mwcmwc » 24 Dec 2011, 18:42

Hi guys,
I started using two controllers this week, and have encountered the same problem. Running windows 7 64 bit and latest version of STK. Controllers are generic dual wired controllers, but when using both to play, have a problem at beginning of race, freezes and stops responding.
Can you walk me through the fix, as i am not accustomed to going to the guts of programs, and i don't want to mess it all up. :? Thanks
mwcmwc
 
Posts: 52
Joined: 11 Dec 2011, 05:53

Re: segfault with two joysticks

Postby Auria » 25 Dec 2011, 18:53

mwcmwc {l Wrote}:Hi guys,
I started using two controllers this week, and have encountered the same problem. Running windows 7 64 bit and latest version of STK. Controllers are generic dual wired controllers, but when using both to play, have a problem at beginning of race, freezes and stops responding.
Can you walk me through the fix, as i am not accustomed to going to the guts of programs, and i don't want to mess it all up. :? Thanks


Hi,

since you are on Windows this is not the same issue. Joerg would need to guide you through a debugging session, but he's probably with his family for the holidays so you may need to be patient :)
Image
User avatar
Auria
STK Moderator
 
Posts: 2976
Joined: 07 Dec 2009, 03:52

Re: segfault with two joysticks

Postby Auria » 25 Dec 2011, 18:57

greggler {l Wrote}:i think the problem is inside of the sixad driver and also CirrDeviceLinux.cpp is not being careful
traced it down to line 1720.
info.persistentData.JoystickEvent.Axis[event.number] = event.value;
the event.number must be < NUMBER_OF_AXES which is 6 and the actual value can be in the 20s
so, it was stomping on memory past the end of the array and that is what was zeroing out the fd.

i protected that array index with a check on max safe value and it did resolve the problem with freezing. no more null file descriptor but also no happy working 2 joysticks.
further debugging shows that the buttons presses on the sixaxis are arriving as event type JS_EVENT_AXIS rather than JS_EVENT_BUTTON so i'll see about working with the sixad folks.

thanks for the help though in sending me on the right path


Ok I submitted the irrlicht part of the issue here : https://sourceforge.net/tracker/?func=d ... tid=540676
Image
User avatar
Auria
STK Moderator
 
Posts: 2976
Joined: 07 Dec 2009, 03:52

Re: segfault with two joysticks

Postby greggler » 27 Dec 2011, 06:32

thanks Auria for submitting that to irrlicht. been away for a bit and was going to do that tonight.

btw, the sixad driver fellow says that he is aware of the button presses producing axis events and it is a feature, not a bug.
anyhow, between some config on sixad and protecting that array index in irrlicht it's been fun times with STK!
greggler
 
Posts: 10
Joined: 19 Dec 2010, 05:03

Re: segfault with two joysticks

Postby mwcmwc » 27 Dec 2011, 07:08

Hey guys,
Would really like some help debugging this. Sorry you have been so busy with holidays and such. Anyway....
mwcmwc
 
Posts: 52
Joined: 11 Dec 2011, 05:53

Re: segfault with two joysticks

Postby Auria » 27 Dec 2011, 19:53

mwcmwc {l Wrote}:Hey guys,
Would really like some help debugging this. Sorry you have been so busy with holidays and such. Anyway....


Windows is not the platform I'm most familiar with, but here's what I know. You will need to download and install Visual C++ (the express version is free) from Microsoft. Then follow instructions at http://supertuxkart.sourceforge.net/How ... ws_version . Once you have built STK from source it will be much easier to debug. Yes this is quite a bit complex but I don't think you can debug STK without doing that :(
Image
User avatar
Auria
STK Moderator
 
Posts: 2976
Joined: 07 Dec 2009, 03:52

Re: segfault with two joysticks

Postby mwcmwc » 28 Dec 2011, 02:46

Ok, took me a while but I got Visual c+ installed, and even managed to download the dependency file. Placed the file in supertuxcart.
Now I must laugh at myself because i can't find and open the src/ide/vc10/supertuxkart.sln file. HAHAHA (me laughing at myself...)
So.................... Help?
ready for instructions, thank you.
mwcmwc
 
Posts: 52
Joined: 11 Dec 2011, 05:53

Re: segfault with two joysticks

Postby sj04736 » 28 Dec 2011, 08:26

@mwcmwc:
It sounds like you don't have the full source of SuperTuxKart.
To get the most recent development version, you can proceed in 1 of 2 ways:
1) Go to http://supertuxkart.svn.sourceforge.net ... ain/trunk/ and click the "Download GNU Tarball" button at the bottom of the page. You need to be able to extract .tar.gz files for this to work, and you'll have difficulty testing changes that might fix your issue without downloading all ~150MB all over again.
2) Download and install TortoiseSVN (from http://tortoisesvn.net/) and check-out supertuxkart.svn.sourceforge.net/supertuxkart/main/trunk/ - after the initial download, getting the latest changes is as easy as right clicking on the game folder and selecting update.

Regardless of how you get the source, this "trunk" folder is the one referred to as the root directory in the wiki, and you should be able to find your src/ide/vc10/supertuxkart.sln file.

(Even if you did get the source that way, I just updated the vc10 file so that it will build properly)
Stephen
Role: STK-Addons Developer

Image
User avatar
sj04736
 
Posts: 146
Joined: 07 Dec 2009, 02:56
Location: Western Canada

Re: segfault with two joysticks

Postby mwcmwc » 29 Dec 2011, 00:28

Ok, so I got tortoise all loaded up, and am ready to export. Got a warning message saying "The target folder is not empty C:\Program Files (x86)\SuperTuxKart-0.7.3'main is not empty". Before I take any further action I just want to make sure i am doing this correctly.
The Url of repository is --- http://supertuxkart.svn.sourceforge.net ... ain/trunk/ -- going into -- C:\Program Files (x86)\SuperTuxKart-0.7.3\main
Am I right?
(ps: thank's everyone for being so patient and kind)
mwcmwc
 
Posts: 52
Joined: 11 Dec 2011, 05:53

Who is online

Users browsing this forum: No registered users and 1 guest