From: David B. <dav...@gm...> - 2012-04-10 13:48:26
|
Hi - thanks for this important fix. David Bruce On Tue, Apr 10, 2012 at 12:43 AM, Kento Locatelli <me...@kl...>wrote: > Hey all, > > I was bored so I cross-compiled TuxMath for Windows, but the game kept > quitting when I tried to start a mission. Seg Fault! > http://pastie.org/3759844 > > After mucking around in gdb, I found and fixed the problem... I attached > the diff git gave me since I don't have write access to the git repo (diff > for the head of the tuxmath t4k-0.1.1 branch). I haven't used C since > high-school, so it might not be the ideal way... > > Basically the problem is the MC_MathGame instance's question pointers are > never explicitly initialized to null. The contents of the memory block > malloc returns are implementation dependent, and on Windows apparently that > can mean a block of memory filled with 0xbaadf00d [1]. Since MC_Initialize > doesn't initialize the question pointers, we're left with a bunch of > not-null pointers to invalid memory... obviously a problem. So, the simple > fix is to explicitly initialize them to null. > > Note: this isn't currently a problem on linux - which zeroes memory that > wasn't previously allocated to the program (for security) - nor is there a > problem with the Windows executable on the site - which was built back when > MC_MathQuestion were globals that were explicitly initialized to null. > > Cheers! > Kento Locatelli > > [1] https://en.wikipedia.org/wiki/**Magic_number_(programming)#** > Magic_debug_values<https://en.wikipedia.org/wiki/Magic_number_(programming)#Magic_debug_values>< > https://en.wikipedia.org/**wiki/Magic_number_%** > 28programming%29#Magic_debug_**values<https://en.wikipedia.org/wiki/Magic_number_%28programming%29#Magic_debug_values>> > > > > ------------------------------------------------------------------------------ > Better than sec? Nothing is better than sec when it comes to > monitoring Big Data applications. Try Boundary one-second > resolution app monitoring today. Free. > http://p.sf.net/sfu/Boundary-dev2dev > _______________________________________________ > Tuxmath-devel mailing list > Tux...@li... > https://lists.sourceforge.net/lists/listinfo/tuxmath-devel > > -- David Bruce For all your software needs, visit The Apt Store: deb http://ftp.us.debian.org/debian stable main |