Version: 2.2 (using KDE KDE 3.1.4) Installed from: Compiled From Sources Compiler: gcc 3.3.2 OS: Linux There is a bug in the collision detection code for powerups. Hitting the shield key at the exact moment a powerup hits the ship (not easy to do, but it happens from time to time) causes a segfault. in view.cpp (kde 3.1.4) line 813 there is a loop to detect powerup collisions. It does not correctly handle the situation where a powerup hits both the ship and shield at the same time. The first time thru the loop the code handles the powerup colliding with the ship. It is processed and deleted from the list. The second time thru the loop the code tries to process the powerup hitting the shield, but since it has already been removed we get a segfault. The fix is to add a break after line 842 (vitalschanged = true). There is no need to check for further collisions anyways since the powerup was collected. I can attach a patch if that makes things clearer. -Todd
Created attachment 3471 [details] fix powerup collision detection problem diff to kasteroids/view.cpp in kde version 3.1.4
Created attachment 3480 [details] Backtrace of kasteroids collision segfault Qt: 3.2.3 KDE: 3.1.4 KAsteroids: 2.2
CVS commit by waba: Fix crash when both shield and ship hit powerup at same time. (BR69324) CCMAIL: 69324-done@bugs.kde.org M +4 -2 view.cpp 1.40.2.1 --- kdegames/kasteroids/view.cpp #1.40:1.40.2.1 @@ -783,7 +783,7 @@ void KAsteroidsView::processPowerups() QPtrListIterator<KPowerup> it( powerups ); - for( ; it.current(); ++it ) + for( ; (pup = it.current()); ) { - pup = it.current(); + ++it; // We have to increase here, because pup may get deleted. pup->growOlder(); @@ -828,4 +828,5 @@ void KAsteroidsView::processPowerups() powerups.removeRef( pup ); vitalsChanged = true; + break; } @@ -835,4 +836,5 @@ void KAsteroidsView::processPowerups() { powerups.removeRef( pup ); + break; } }