Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.5.2pre.1305] Freeze after engaging with the Sat Com relay #390

Closed
Eonfge opened this issue Jun 21, 2021 · 5 comments
Closed

[1.5.2pre.1305] Freeze after engaging with the Sat Com relay #390

Eonfge opened this issue Jun 21, 2021 · 5 comments

Comments

@Eonfge
Copy link
Contributor

Eonfge commented Jun 21, 2021

I ran into a reproducible issue with Dhewm3, which freezes the game completely. It happens just after I cancelled the distress signal. When loading the quicksave, All I do is a step forward and looking to the left, and the game freezes.

Save game:
QuickSave.zip

Log:
Dhewm3FreezeLog.txt

The log is sadly useless I fear, since the issue freezes the machine, forcing me to use gdb to terminate the program. When running without gdb, the issue also happens and I have to kill the task instead. As always, if you need more info, feel free to ask.

@DanielGibson
Copy link
Member

I haven't tried the savegame yet. Generally what could help is getting a backtrace of all threads (looks like the main thread is waiting for another thread to signal it can go on). This can be done (in gdb) with:
thread apply all backtrace

@Eonfge
Copy link
Contributor Author

Eonfge commented Jun 21, 2021

Wow, thanks for your quick comment. I'm really learning a lot about gdb now. Anyway, here is the log because it really takes me less then a minute to reproduce:

Thread 1 "dhewm3" received signal SIGINT, Interrupt.
0x00007ffff7c23e82 in pthread_cond_wait () from /usr/lib/x86_64-linux-gnu/libpthread.so.0
(gdb) thread apply all backtrace

Thread 6 (Thread 0x7ffff18c3700 (LWP 13)):
#0  0x00007ffff7c26a04 in do_futex_wait.constprop () from /usr/lib/x86_64-linux-gnu/libpthread.so.0
#1  0x00007ffff7c26b08 in __new_sem_wait_slow.constprop.0 () from /usr/lib/x86_64-linux-gnu/libpthread.so.0
#2  0x00007ffff7ee6482 in al::semaphore::wait() () from /usr/lib/x86_64-linux-gnu/libopenal.so.1
#3  0x00007ffff7e71951 in EventThread(ALCcontext*) () from /usr/lib/x86_64-linux-gnu/libopenal.so.1
#4  0x00007ffff7af5a74 in execute_native_thread_routine () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#5  0x00007ffff7c1d4d2 in start_thread () from /usr/lib/x86_64-linux-gnu/libpthread.so.0
#6  0x00007ffff77e0323 in clone () from /usr/lib/x86_64-linux-gnu/libc.so.6

Thread 5 (Thread 0x7ffff20c4700 (LWP 12)):
#0  0x00007ffff77d553f in poll () from /usr/lib/x86_64-linux-gnu/libc.so.6
#1  0x00007ffff7edbcb9 in (anonymous namespace)::pulse_poll_func(pollfd*, unsigned long, int, void*) () from /usr/lib/x86_64-linux-gnu/libopenal.so.1
#2  0x00007ffff2ddc961 in pa_mainloop_poll () from /usr/lib/x86_64-linux-gnu/libpulse.so.0
#3  0x00007ffff2ddcfe3 in pa_mainloop_iterate () from /usr/lib/x86_64-linux-gnu/libpulse.so.0
#4  0x00007ffff2ddd090 in pa_mainloop_run () from /usr/lib/x86_64-linux-gnu/libpulse.so.0
#5  0x00007ffff7edbe1f in (anonymous namespace)::PulseMainloop::mainloop_thread() () from /usr/lib/x86_64-linux-gnu/libopenal.so.1
#6  0x00007ffff7af5a74 in execute_native_thread_routine () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#7  0x00007ffff7c1d4d2 in start_thread () from /usr/lib/x86_64-linux-gnu/libpthread.so.0
#8  0x00007ffff77e0323 in clone () from /usr/lib/x86_64-linux-gnu/libc.so.6

Thread 4 (Thread 0x7ffff28c5700 (LWP 11)):
#0  0x00007ffff77d553f in poll () from /usr/lib/x86_64-linux-gnu/libc.so.6
#1  0x00007ffff7edbcb9 in (anonymous namespace)::pulse_poll_func(pollfd*, unsigned long, int, void*) () from /usr/lib/x86_64-linux-gnu/libopenal.so.1
#2  0x00007ffff2ddc961 in pa_mainloop_poll () from /usr/lib/x86_64-linux-gnu/libpulse.so.0
#3  0x00007ffff2ddcfe3 in pa_mainloop_iterate () from /usr/lib/x86_64-linux-gnu/libpulse.so.0
#4  0x00007ffff2ddd090 in pa_mainloop_run () from /usr/lib/x86_64-linux-gnu/libpulse.so.0
#5  0x00007ffff7edbe1f in (anonymous namespace)::PulseMainloop::mainloop_thread() () from /usr/lib/x86_64-linux-gnu/libopenal.so.1
#6  0x00007ffff7af5a74 in execute_native_thread_routine () from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#7  0x00007ffff7c1d4d2 in start_thread () from /usr/lib/x86_64-linux-gnu/libpthread.so.0
#8  0x00007ffff77e0323 in clone () from /usr/lib/x86_64-linux-gnu/libc.so.6

Thread 3 (Thread 0x7ffff3630700 (LWP 10)):
#0  0x00007ffff7c23e82 in pthread_cond_wait () from /usr/lib/x86_64-linux-gnu/libpthread.so.0
#1  0x00007ffff7d316b2 in SDL_CondWait_REAL () from /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0
#2  0x0000555555774383 in Sys_WaitForEvent (index=<optimized out>) at sys/threads.cpp:195
#3  0x00005555556617be in BackgroundDownloadThread (pexit=0x555555ca4f60 <fileSystemLocal+1312>) at framework/FileSystem.cpp:3422
#4  0x00007ffff7cbbd40 in SDL_RunThread () from /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0
#5  0x00007ffff7d30d0d in RunThread () from /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0
#6  0x00007ffff7c1d4d2 in start_thread () from /usr/lib/x86_64-linux-gnu/libpthread.so.0
#7  0x00007ffff77e0323 in clone () from /usr/lib/x86_64-linux-gnu/libc.so.6

Thread 2 (Thread 0x7ffff6a84700 (LWP 9)):
#0  0x000055555562cacb in idCommonLocal::DPrintf (this=<optimized out>, fmt=<optimized out>) at ./framework/CVarSystem.h:146
#1  0x000055555571d06d in idSampleDecoderLocal::DecodeOGG (this=this@entry=0x55556765a0a0, sample=sample@entry=0x55555c226130, sampleOffset44k=sampleOffset44k@entry=1454658, sampleCount44k=sampleCount44k@entry=1446, dest=dest@entry=0x7ffff6a7b9e0) at ./idlib/Str.h:501
#2  0x000055555571d353 in idSampleDecoderLocal::Decode (this=0x55556765a0a0, sample=0x55555c226130, sampleOffset44k=1454658, sampleCount44k=1446, dest=0x7ffff6a7b9e0) at sound/snd_decoder.cpp:462
#3  0x000055555571fe1e in idSoundChannel::GatherChannelSamples (this=0x5555670c80e0, sampleOffset44k=1454658, sampleCount44k=8192, dest=<optimized out>) at sound/snd_emitter.cpp:329
#4  0x0000555555728d3f in idSoundWorldLocal::AddChannelContribution (this=<optimized out>, sound=<optimized out>, chan=0x5555670c80e0, current44kHz=<optimized out>, numSpeakers=6, finalMixBuffer=0x5555583e3450 <soundSystemLocal+48>) at sound/snd_world.cpp:1894
#5  0x00005555557292da in idSoundWorldLocal::MixLoop (this=0x5555594535a0, current44kHz=677199, numSpeakers=6, finalMixBuffer=0x5555583e3450 <soundSystemLocal+48>) at sound/snd_world.cpp:598
#6  0x00005555557234c2 in idSoundSystemLocal::AsyncUpdateWrite (inTime=15356, this=<optimized out>) at sound/snd_system.cpp:804
#7  idSoundSystemLocal::AsyncUpdateWrite (this=0x5555583e3420 <soundSystemLocal>, inTime=15356) at sound/snd_system.cpp:790
#8  0x00005555556300b5 in idCommonLocal::SingleAsyncTic (this=<optimized out>) at framework/Common.cpp:2507
#9  0x0000555555630178 in idCommonLocal::Async (this=0x555555c30720 <commonLocal>) at framework/Common.cpp:2560
#10 0x000055555562d2c5 in AsyncTimer (interval=<optimized out>) at framework/Common.cpp:2750
#11 0x00007ffff7cbc3d2 in SDL_TimerThread () from /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0
#12 0x00007ffff7cbbd40 in SDL_RunThread () from /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0
#13 0x00007ffff7d30d0d in RunThread () from /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0
#14 0x00007ffff7c1d4d2 in start_thread () from /usr/lib/x86_64-linux-gnu/libpthread.so.0
#15 0x00007ffff77e0323 in clone () from /usr/lib/x86_64-linux-gnu/libc.so.6

Thread 1 (Thread 0x7ffff6a87fc0 (LWP 5)):
#0  0x00007ffff7c23e82 in pthread_cond_wait () from /usr/lib/x86_64-linux-gnu/libpthread.so.0
#1  0x00007ffff7d316b2 in SDL_CondWait_REAL () from /usr/lib/x86_64-linux-gnu/libSDL2-2.0.so.0
#2  0x0000555555774383 in Sys_WaitForEvent (index=<optimized out>) at sys/threads.cpp:195
#3  0x00005555556836f2 in idSessionLocal::Frame (this=0x555555ca74e0 <sessLocal>) at framework/Session.cpp:2616
#4  0x000055555562dafd in idCommonLocal::Frame (this=0x555555c30720 <commonLocal>) at framework/Common.cpp:2413
#5  0x0000555555584bcd in main (argc=1, argv=0x7fffffffdd88) at sys/linux/main.cpp:429

Dhewm3FreezeLog2.txt

DanielGibson added a commit that referenced this issue Jun 22, 2021
In idSampleDecoderLocal::DecodeOGG() `totalSamples` was 1 and
`reqSamples` was 0, which caused an endless loop.. this was caused by
idSoundWorldLocal::ReadFromSaveGame() setting
`chan->openalStreamingOffset` to an odd number, I think due to
`currentSoundTime` being an odd number.
To fix that, I round up `chan->openalStreamingOffset` to a (very) even
number, and to be double-sure I also added a check in DecodeOgg() to
make sure it exits the loop if `reqSamples` is 0.
@DanielGibson
Copy link
Member

Thanks for reporting!
I could reproduce the issue and just pushed a fix to the git master branch - can you test if this works for you as well?

(This issue was introduced after 1.5.1 when overhauling the .ogg reading code)

@Eonfge
Copy link
Contributor Author

Eonfge commented Jun 22, 2021

That's it, the freeze is gone and I can continue my fight for mankind's survival.

@Eonfge Eonfge closed this as completed Jun 22, 2021
@DanielGibson
Copy link
Member

Thanks for the confirmation and good luck with the fight!

rorgoroth pushed a commit to rorgoroth/dhewm3 that referenced this issue Apr 8, 2023
In idSampleDecoderLocal::DecodeOGG() `totalSamples` was 1 and
`reqSamples` was 0, which caused an endless loop.. this was caused by
idSoundWorldLocal::ReadFromSaveGame() setting
`chan->openalStreamingOffset` to an odd number, I think due to
`currentSoundTime` being an odd number.
To fix that, I round up `chan->openalStreamingOffset` to a (very) even
number, and to be double-sure I also added a check in DecodeOgg() to
make sure it exits the loop if `reqSamples` is 0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants