View Issue Details

IDProjectCategoryView StatusLast Update
0004803The Dark ModSound Systempublic29.05.2018 16:36
Reporterstgatilov Assigned Tostgatilov  
PrioritylowSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product VersionTDM 2.06 
Target VersionTDM 2.07Fixed in VersionTDM 2.07 
Summary0004803: TDM crashes if looping sound plays for 6+ hours
DescriptionThis was noticed by Goldwell and explained here:
  http://forums.thedarkmod.com/topic/18982-tdm-206/page-30#entry422092

Steps To Reproduce1. Start TDM game
2. Leave it for 7 hours (or 15 hours to be sure).
Currently TDM crashes after 6-7 hours.
Additional InformationThis is caused by overflow in "chan->openalStreamingOffset": it grows with speed +44100 per second (using +4096 steps), and when it reaches 2^30 TDM crashes in idSoundChannel::GatherChannelSamples due to sampleOffset44k = -2^31.
TagsNo tags attached.

Activities

duzenko

duzenko

29.05.2018 10:27

developer   ~0010477

Last edited: 29.05.2018 10:33

View 2 revisions

chan->openalStreamingOffset += MIXBUFFER_SAMPLES;
if(chan->openalStreamingOffset<0)
  chan->openalStreamingOffset = 0;
?

Can it ever be negative outside of overflow? If no, change idSoundChannel::GatherChannelSamples to unsigned int?

Make use of int64?

stgatilov

stgatilov

29.05.2018 13:54

administrator   ~0010481

Last edited: 29.05.2018 13:54

View 2 revisions

I think it could.
Otherwise you have to ensure that start time of sound is never greater than current time. It is a dangerous assertion (some part of sound system works in another thread).

I have already fixed the problem locally by restarting the sound channel when its offset gets too large.
This is not very nice (sound restarts), but it is simple and it surely does not affect anyone unless they listen to the same sound 6 hours without pause. So this sound restart happens only after 6 hours, and only once per 6 hours...

Now I am waiting for 15-hours experiment to complete =)

stgatilov

stgatilov

29.05.2018 13:55

administrator   ~0010482

Here is the suggested fix:

// 0004803 stgatilov: avoid offset overflow (which causes crash)
if (chan->openalStreamingOffset * sample->objectInfo.nChannels > INT_MAX - (1<<20)) {
    //simply restart this sound (happens after 6.75 hours of repetition)
    chan->trigger44kHzTime = current44kHz;
    chan->openalStreamingOffset = 0;
    common->Warning("Restarted sound to avoid offset overflow: %s", chan->leadinSample->name.c_str());
}
stgatilov

stgatilov

29.05.2018 16:35

administrator   ~0010483

Fixed in svn rev 7423.

Issue History

Date Modified Username Field Change
28.05.2018 14:49 stgatilov New Issue
28.05.2018 14:49 stgatilov Status new => assigned
28.05.2018 14:49 stgatilov Assigned To => stgatilov
29.05.2018 10:27 duzenko Note Added: 0010477
29.05.2018 10:33 duzenko Note Edited: 0010477 View Revisions
29.05.2018 13:54 stgatilov Note Added: 0010481
29.05.2018 13:54 stgatilov Note Edited: 0010481 View Revisions
29.05.2018 13:55 stgatilov Note Added: 0010482
29.05.2018 16:35 stgatilov Note Added: 0010483
29.05.2018 16:36 stgatilov Status assigned => resolved
29.05.2018 16:36 stgatilov Fixed in Version => TDM 2.07
29.05.2018 16:36 stgatilov Resolution open => fixed