[Debian-lego-team] Bug#848962: nqc: Segfaults with -TSwan -L

Petter Reinholdtsen pere at hungry.com
Wed Aug 2 06:54:19 UTC 2017


Control: tags -1 + patch

I had a look at this issue, and tracked it down to
calculateInstructionLengths() trying to the const array
nSwanInstructionLength.  With recent compilers and operating
systems, 'const' variables are placed in a read only memory
segment, thus causing this 'bad permission' crash.

The fix is simply to remove the 'const' like this:

diff --git a/rcxlib/RCX_Disasm.cpp b/rcxlib/RCX_Disasm.cpp
index ee38608..0229e11 100644
--- a/rcxlib/RCX_Disasm.cpp
+++ b/rcxlib/RCX_Disasm.cpp
@@ -489,8 +489,8 @@ public:
        long    fOffset;
 };
 
-// Swan support code
-const ubyte nSwanInstructionLength[256] = {
+// Swan support code.  This array is updated at runtime.
+ubyte nSwanInstructionLength[256] = {
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,

I've applied this in debian/patches/writable-swap-inst-len.patch
in git.
-- 
Happy hacking
Petter Reinholdtsen



More information about the Debian-lego-team mailing list