bug in 'h' length modifier of [format] on AIX 5/64 & Tru64
Closed / Fixed1154163fffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 21 years ago
Descriptionplain2005-03-01 11:48:17
OS: % parray tcl_platform tcl_platform(byteOrder) = littleEndian tcl_platform(machine) = alpha tcl_platform(os) = OSF1 tcl_platform(osVersion) = V5.1 tcl_platform(platform) = unix tcl_platform(user) = makr tcl_platform(wordSize) = 8 [format] returns another format string instead of result: % format "%hx" 1 lx % format "%hu" 1 lu % format "%hd" 1 ld % format "%hi" 1 ld Expected same behavior as on Solaris 8 / 64 bit: OS: % parray tcl_platform tcl_platform(byteOrder) = bigEndian tcl_platform(machine) = sun4u tcl_platform(os) = SunOS tcl_platform(osVersion) = 5.8 tcl_platform(platform) = unix tcl_platform(user) = makr tcl_platform(wordSize) = 8 % format "%hx" 1 1 % format "%hu" 1 1 % format "%hd" 1 1 % format "%hi" 1 1 I suspect the following code to be the trouble maker, although I do not have a clue what it wants to achive ... in tcl8.4.9/generic/tclCmdAH.c: 2205 #if (LONG_MAX > INT_MAX) 2206 /* 2207 * Add the 'l' for long format type because we are on an 2208 * LP64 archtecture and we are really going to pass a long 2209 * argument to sprintf. 2210 */ 2211 newPtr++; 2212 *newPtr = 0; 2213 newPtr[-1] = newPtr[-2]; 2214 newPtr[-2] = 'l'; 2215 #endif /* LONG_MAX > INT_MAX */ kind regards -- Matthias Kraft
matzekplain2005-03-01 19:26:51
Logged In: YES user_id=330806 Well, I was right ... Inserting printf()s before and after that code shows: % format "%hx" 1 >>> format: %hx >>> format: %hlx lx And removing the lines 2211 up to and including 2213 now returns the correct result: % format "%hx" 0x12480 >>> format: %hx >>> format: %lx 2480 What's the drawback? kind regards -- Matthias Kraft
matzekplain2005-03-03 23:27:10
Logged In: YES
user_id=330806
Well, despite the fact Tcl can only be called in batch mode
on AIX 5.1 / 64 bit - see bug: [ 1155891 ] TEBC segfaults
(AIX 5.1 / 64 bit) - it also reveals format is also not
working correctly here:
/RDS/COMPSRV/prog/makr/tcl8.4.9/unix$ echo "puts [format
\"%hx\" 0x12340]\n" > crashtest.tcl
/RDS/COMPSRV/prog/makr/tcl8.4.9/unix$
/RDS/COMPSRV/prog/makr/tcl-8.4.9/bin/tclsh8.4 ./crashtest.tcl
lx
Raising priority, because this is a platform I will need 64
bit support in the near future, while Tru64 is dying out...
kind regards
-- Matthias Kraft
msoferplain2005-03-03 23:33:24
Logged In: YES user_id=148712 I'd keep this in the backburner until we sort out 1155891: that one looks like mem corruption. This bug may just be a symptom ...
dkf Ticket [1154163fff]: 1 change
[History diff]2005-03-08 04:30:29
dkfplain2005-03-08 04:30:30
Logged In: YES user_id=79902 Looks to me like we need to ensure that h is not mixed with l (or ll, but that's a 32-bit machine thing). Approximately, h=>16-bit, no-mod=>32-bit/machine-word, l=>64-bit, so mixing them doesn't make sense...
dkfplain2005-06-18 06:42:43
Logged In: YES user_id=79902 I think I've fixed this now (8.4 branch and HEAD). Sorry for taking so long
Log in (anonymous is fine) to add a comment.