snd_playing Engine Crash

Posted By: Error014

snd_playing Engine Crash - 07/22/17 01:12

Hello, everyone.

In my game, I got an extremely rare crash. After playing for 15 (if I'm lucky), usually 30+ minutes, the game crashes:

Quote:
Error E1513: Script crash in pushblock@1: pba


I've placed "sys_marker" all over the place there, so we can tell exactly where the game crashes:

Code:
...
if(soundvol>0 && sndhandle!=0) {
sys_marker("pba"); //HERE IS WHERE IT CRASHED
if(snd_playing(sndhandle)>0) {
   sys_marker("psa");
...



I know that there's the engine parameter sound_vol, but I'm using soundvol - a variable I've defined - for this purpose.

Since "pba" fired, but "psa" did not, the line in question that crashes is therefore the "snd_playing" one.

Of course, this particular piece of code works almost everytime, with the same sound playing. Here's the sound playing code

Code:
sndhandle = ent_playloop2(whoToPush,snd_moveblock,20*soundvol/100,999999);



(sndhandle gets set to 0 on initialization, which also explains the other part of the if-condition)

The range parameter is very high, granted - and larger than the range given in the manual, but that shouldn't explain random crashes, right? In any case, I've strongly reduced the range.

What could cause this behaviour?


EDIT: Welp, apparently, there's a thread from 2013 about this, spawning a subsequent Bug Report - though I do not use PhysX. With no real fix...
Posted By: jumpman

Re: snd_playing Engine Crash - 07/22/17 04:54

sndhandle = ent_playloop2(...)

What happens to the sndhandle variable when this instruction happens? Does it store a numerical value? Is this variable a unique identifier of that played sound? Is sndhandle a global or local variable?

Monitor this value and see what it stores normally when its assigned to an ent_playloop, and then see if this value changes right before the crash?

Create a test level with the block being pushed infinitely by the player/ai and see if it crashes after a certain amount of time. Make sure no other entities are in this test level. Run the level over again and see if it crashes consistently past the 15 min mark.

Will it still crash if you used snd_play?, or regular ent_playloop?
Posted By: Error014

Re: snd_playing Engine Crash - 07/22/17 11:35

sndhandle is a local variable, which is only used in the snd_-instructions you see here (and in the sndhandle!=0-check, also shown above).

I have for now replaced ent_playloop with snd_loop, because of the suggestion in the Bug Report thread I've linked above. I'll let you know if it crashes again!
Posted By: DriftWood

Re: snd_playing Engine Crash - 07/22/17 16:03

Here are some thoughts.
E1513 bad reference to pointer/handle. The handle is not a var alone its reference to an object. It must be valid. This error is almost always a bad pointer.

I'd use
if(ptr_for_handle(sndhandle) != null)
Stead of if(sndhandle != 0)

Not that there is much difference, but just because a Handle holds a
value, that doesn't mean it's a valid value.

Other manual quotes.
http://www.conitec.net/beta/aent_playsound.htm
Quote:
The entity must already be initialized at the time the sound is played. Thus the sound can be played 1 frame cycle after entity creation the earliest.


Of course you'd be safer to wait(1) after Entity creation and wait(1) after the _play instructions before testing for the snd_playing.
© 2024 lite-C Forums