Ticket UUID: | 1090869 | |||
Title: | Tcl_GetInt Returns Illegal Overlfow On AMD64 | |||
Type: | Bug | Version: | None | |
Submitter: | sanjeev_singh | Created on: | 2004-12-24 15:43:52 | |
Subsystem: | 11. Conversions from String | Assigned To: | dgp | |
Priority: | 5 Medium | Severity: | ||
Status: | Closed | Last Modified: | 2005-04-20 23:05:17 | |
Resolution: | Fixed | Closed By: | dgp | |
Closed on: | 2005-04-20 16:05:17 | |||
Description: |
Hi, I am running on Opteron ie Amd 64 bit mc. While porting my 32 bit code I am running into this problem with reading 32 bit numbers that have bit 31 set. Basically the code below fails if the user passed 0x8000000 as the arguments. int tb_test(ClientData dummy, Tcl_Interp *interp, int argc, char **argv) { int code = TCL_OK; int value[2]; Tcl_GetInt(interp, argv[1], &value[0]); Tcl_GetInt(interp, argv[2], &value[1]); printf("VALUE0=0x%x\n", value[0]); printf("VALUE1=0x%x\n", value[1]); return code; } When run in tclsh this gives % myCmd 0x7fffffff 0x80000000 VALUE0=0x7fffffff VALUE1=0x0 integer value too large to represent % The problem seems to be in file tclGet.c in the following line- if ((errno == ERANGE) || (((long)(int) i) != i)) { It should be instead if ((errno == ERANGE) || (((long)(unsigned int) i) != i)) { -sanjeev | |||
User Comments: |
dgp added on 2005-04-20 23:05:17:
Logged In: YES user_id=80530 Fixed for 8.4.10 and 8.5a3 dgp added on 2005-04-20 04:08:19: File Deleted - 130958: File Added - 130971: 1090869.patch dgp added on 2005-04-20 04:08:15: Logged In: YES user_id=80530 ok, try this patch instead. dgp added on 2005-04-20 02:44:31: File Deleted - 130943: File Added - 130958: 1090869.patch dgp added on 2005-04-20 02:44:30: Logged In: YES user_id=80530 New patch also fixes (and simplifies) Tcl_GetIntFromObj(). Please review and commit if acceptable. dgp added on 2005-04-20 01:20:12: File Added - 130943: 1090869.patch dgp added on 2005-04-20 01:20:10: Logged In: YES user_id=80530 Here's a different patch to try. dgp added on 2005-04-20 00:36:30: Logged In: YES user_id=80530 In particular, after that patch the value "-1" becomes "too large to represent" dgp added on 2005-04-20 00:33:01: Logged In: YES user_id=80530 That proposed patch fails 54 tests in the test suite. |
Attachments:
- 1090869.patch [download] added by dgp on 2005-04-20 04:08:17. [details]