4klang
4klang copied to clipboard
Offset into delay buffer gets corrupted for some builds
For some of the builds 4klang will reliably crash on either this https://github.com/hzdgopher/4klang/blob/e28554120325fcaaebbe8189eef16b57fd83f0a8/4klang_source/4klang.asm#L930 or this https://github.com/hzdgopher/4klang/blob/e28554120325fcaaebbe8189eef16b57fd83f0a8/4klang_source/4klang.asm#L962 lines just 10-20 seconds into synthesized music. eax looks unreasonable.
It seems like go4kDLL_wrk.index value gets corrupted. Not sure where, when and why exactly.
Padding it with 256 bytes (not tried other values really) prevented crashing for at least one of the tunes on a slightly older version of 4klang (doesn't seem to help the latest version from this repo):
struc go4kDLL_wrk
+ .padding resd 64
.index resd 1
+ .padding2 resd 64
The crash may happen on both Windows and Linux for binaries built with their default linkers. The crash rarely happens if the binary was linked using Crinkler, but everything else was exactly the same. In rare cases it is possible to randomly tweak e.g. asm/C source of the intro in such a way that a "debug" (not linked using Crinkler) binary won't crash.
Almost all of jetlag 4k intros are affected by this problem :D.
Hi Ivan,
could you (or keen) provide me with the respective asm/inc files that reliably crash before you start the padding?