From: Markus Armbruster Date: Mon, 29 Apr 2013 19:28:17 +0000 (+0200) Subject: Fix five year old show stopper bugs on big endian hosts X-Git-Tag: v4.3.31~24 X-Git-Url: http://git.pond.sub.org/?p=empserver;a=commitdiff_plain;h=c016c5fe761bd94349743f9e6a60ba858afa3b0f Fix five year old show stopper bugs on big endian hosts emp_server and empdump refuse to start on most big endian hosts, because ef_verify_config() chokes on mdchr_ca[]: Config meta uid 0 field type: value 0 is not in symbol table meta-type Config meta uid 1 field type: value 0 is not in symbol table meta-type Config meta uid 2 field type: value 0 is not in symbol table meta-type Config meta uid 3 field type: value 0 is not in symbol table meta-type Config meta uid 4 field type: value 0 is not in symbol table meta-type Broken in commit 06a0036 (v4.3.12), which changed struct castr member ca_type from packed_nsc_type (typedef'ed to char) to enum nsc_type, but neglected to update the ca_type in mdchr_ca[]. On little endian hosts, the selector reads the least significant byte, with sign extension. Happens to work, because the type values are all sufficiently small integers. On big endian hosts, the selector reads the most signiciant byte. which is always zero (NSC_NOTYPE). Makes ef_verify_config() fail. Except when sizeof(enum nsc_notype) == 1. Then selector type works fine, and ef_verify_config() succeeds, but we run into the next problem: the same commit also changed member ca_flags from nsc_flags (typedef'ed to unsigned char) to int without updating the ca_type in mdchr_ca[]. This breaks "only" xdump meta column flags. v4.3.12 was released in April 2008. Either nobody has tried to run a game on a big endian host since, or all who did gave up quietly, without reporting the problem. We clearly need to test on a wider range of machines. --- diff --git a/src/lib/common/nsc.c b/src/lib/common/nsc.c index 0178e822c..3685a9274 100644 --- a/src/lib/common/nsc.c +++ b/src/lib/common/nsc.c @@ -686,8 +686,9 @@ struct castr mdchr_ca[] = { /* no need for uid */ /* name must come first, clients may rely on it */ {"name", fldoff(ca_name), NSC_STRING, 0, NULL, EF_BAD, NSC_CONST}, - {"type", fldoff(ca_type), NSC_CHAR, 0, NULL, EF_META_TYPE, NSC_CONST}, - {"flags", fldoff(ca_flags), NSC_UCHAR, 0, NULL, + {"type", fldoff(ca_type), NSC_SITYPE(enum nsc_type), 0, NULL, + EF_META_TYPE, NSC_CONST}, + {"flags", fldoff(ca_flags), NSC_INT, 0, NULL, EF_META_FLAGS, NSC_CONST | NSC_BITS}, {"len", fldoff(ca_len), NSC_USHORT, 0, NULL, EF_BAD, NSC_CONST}, {"table", fldoff(ca_table), NSC_INT, 0, NULL, EF_TABLE, NSC_CONST}, diff --git a/tests/smoke/smoke.out b/tests/smoke/smoke.out index d1df77f86..394d493c1 100644 --- a/tests/smoke/smoke.out +++ b/tests/smoke/smoke.out @@ -632,8 +632,8 @@ Player 00 Turn 00 starting [0:640] Command : XDUMP meta meta 0 "name" 3 4 0 -1 -"type" 4 4 0 34 -"flags" 5 12 0 33 +"type" 8 4 0 34 +"flags" 8 12 0 33 "len" 7 4 0 -1 "table" 8 4 0 27 /5 @@ -1519,8 +1519,8 @@ CENSUS del dst [0:636] Command : XDUMP meta meta 0 "name" 3 4 0 -1 -"type" 4 4 0 34 -"flags" 5 12 0 33 +"type" 8 4 0 34 +"flags" 8 12 0 33 "len" 7 4 0 -1 "table" 8 4 0 27 /5