Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
AGOS: Fix compatibility with strict-alignment architectures #2241
Proposed fix for a bug I've reported some years ago:
SIMON2-FR would crash really early with a SIGBUS on OpenBSD/loongson, which is a mips64el system with strict alignment constraints.
(Maybe alignTableMem() could be optimised a bit, but I'm not sure it's worth it.)
Tested with SIMON2-FR and SIMON1-FR on OpenBSD/loongson and on macOS Mojave (x86-64).
I don't really know how to test the "running out of memory" possible case that lordhoto reported above, though. Don't know which platform or use case would be more likely to hit it.
Make sure that alignTableMem() always aligns to an 8 byte boundary on 64-bit architectures where this is the usual size of pointers. Also make sure that loadTextIntoMem() always calls alignTableMem(). This has been tested on OpenBSD/loongson (a mips64el architecture which requires strict alignment), with clang++ 8.0.1 and simon2-cd-fr. Fixes bug #6220.
@dwatteau : Thank you for the patch for this bug in the AGOS engine which has been open for quite a while. Hopefully an AGOS engine dev will review this shortly. If not, then I will give your patch a basic test with my copies of AGOS games to see if this seems good...