Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Tcl_GetInt Returns Illegal Overlfow On AMD64

Closed / Fixed1090869fffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 22 years ago
Descriptionplain2004-12-24 15:43:52
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
msofer Ticket [1090869fff]: 1 change [History diff]2005-04-16 22:44:44
dgpplain2005-04-20 00:33:01
Logged In: YES 
user_id=80530


That proposed patch fails 54 tests
in the test suite.
dgpplain2005-04-20 00:36:30
Logged In: YES 
user_id=80530


In particular, after that patch
the value "-1" becomes
"too large to represent"
dgpplain2005-04-20 01:20:10
Logged In: YES 
user_id=80530


Here's a different patch to try.
dgpplain2005-04-20 01:20:12
File Added - 130943: 1090869.patch
dgpplain2005-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.
dgpplain2005-04-20 02:44:31
File Deleted - 130943: 



File Added - 130958: 1090869.patch
dgpplain2005-04-20 04:08:15
Logged In: YES 
user_id=80530

ok, try this patch instead.
dgpplain2005-04-20 04:08:19
File Deleted - 130958: 



File Added - 130971: 1090869.patch
dgpplain2005-04-20 23:05:17
Logged In: YES 
user_id=80530


Fixed for 8.4.10 and 8.5a3
Log in (anonymous is fine) to add a comment.

Attachments: