Strange input error? I have no idea...

Started by
9 comments, last by Zahlman 17 years, 9 months ago
Well. I started my Tetris game in Windows and decided to port it over to Linux today, and when I compile it and all it works great. Until I clear a line. Once a line is cleared it seems that all input is frozen and the program doesn't respond at all to anything! Of course I tried to debug it and such but it looks like nothing is wrong! I know where the part of the code that does it but it's only the part that adds stuff to your score: player->score += (level+1) * 40; That's the line. It doesn't make sense that it would stop all input... but it is. And this might sound strange, but if I put a: print("%i\n", blah); in front of it, it seems to work!? It's confusing me greatly and I would appreciate any help or insight at all :S Here is a tar of the binary... thanks a lot. T_T You probably have to run it in a term and select the button one. Controls: j-left k-down l-right i-rotate space-auto down http://galatron.net/blockktris1.tar
Advertisement
Sounds like you have some sort of heap corruption. Maybe you are writing off the end of an array or have a stray pointer somewhere.

Linux is generally a lot more anal about this kind of thing; you might want to use mmgr.h or efence with your app to make sure it's not doing anything blatantly illegal.
One from the obvious questions camp: are you sure player is pointing to the right thing? If player isn't initialised, player->score is going to write all over something it shouldn't.
Yes. It is initialised. That's something I've checked over and over. :( My problem still isn't fixed either. I've tried MMGR and that isn't really helping at all. :/ Any other suggestions?
Wow... after compiling it with a makefie generated from Codeblocks IDE it... works? Maybe it was my linkage or something? Is that even possible?

[Edited by - DarkNebula on June 28, 2006 10:08:33 AM]
Sure, anything's possible. Usually, though, bugs like this are latent problems that just happen to slip by under some circumstances, but die under other circumstances.
Well then. I guess I have no idea where the bug is. lol
Heisenbugs like this are almost always memory problems. Check your array accesses, use of uninitialized pointers, re-use of freed pointers, etc.
Wow. I got it. I can't believe what it was either. It was some stupid string. char score[20]; Just not enough space. Thanks for the hints about it, I'm surprised I even found it at all. It wasn't even close to the spot where the program was crashing.
No problem. efence would probably have caught your accesses over the end of the array, though mmgr probably should've too.

Enjoy your new Linux game.

This topic is closed to new replies.

Advertisement