tags 398148 + patch thanks Hello,
I can confirm the bug. It is indeed due to chuck assuming that longs are 4 bytes. The attached patch fixes that. Note that I avoided changing the 0x3 mask because as documented it is just an "additional word count" and will already be below 4. Problem is: I do not get any audio output, but that's also the case when I try to run the 32bit version, so I guess that's another bug. Samuel
diff -ur chuck-1.2.0.8.dfsg.orig/src/chuck_instr.cpp chuck-1.2.0.8.dfsg/src/chuck_instr.cpp --- chuck-1.2.0.8.dfsg.orig/src/chuck_instr.cpp 2007-03-22 07:36:02.000000000 +0100 +++ chuck-1.2.0.8.dfsg/src/chuck_instr.cpp 2009-03-23 02:17:31.000000000 +0100 @@ -2527,11 +2527,11 @@ // get the local stack depth - caller local variables t_CKUINT local_depth = *(reg_sp+1); // convert to number of 4-byte words, extra partial word counts as additional word - local_depth = ( local_depth >> 2 ) + ( local_depth & 0x3 ? 1 : 0 ); + local_depth = ( local_depth / sizeof(t_CKUINT) ) + ( local_depth & 0x3 ? 1 : 0 ); // get the stack depth of the callee function args - t_CKUINT stack_depth = ( func->stack_depth >> 2 ) + ( func->stack_depth & 0x3 ? 1 : 0 ); + t_CKUINT stack_depth = ( func->stack_depth / sizeof(t_CKUINT) ) + ( func->stack_depth & 0x3 ? 1 : 0 ); // get the previous stack depth - caller function args - t_CKUINT prev_stack = ( *(mem_sp-1) >> 2 ) + ( *(mem_sp-1) & 0x3 ? 1 : 0 ); + t_CKUINT prev_stack = ( *(mem_sp-1) / sizeof(t_CKUINT) ) + ( *(mem_sp-1) & 0x3 ? 1 : 0 ); // jump the sp mem_sp += prev_stack + local_depth; @@ -2606,11 +2606,11 @@ // get the local stack depth - caller local variables t_CKUINT local_depth = *(reg_sp+1); // convert to number of 4-byte words, extra partial word counts as additional word - local_depth = ( local_depth >> 2 ) + ( local_depth & 0x3 ? 1 : 0 ); + local_depth = ( local_depth / sizeof(t_CKUINT) ) + ( local_depth & 0x3 ? 1 : 0 ); // get the stack depth of the callee function args - t_CKUINT stack_depth = ( func->stack_depth >> 2 ) + ( func->stack_depth & 0x3 ? 1 : 0 ); + t_CKUINT stack_depth = ( func->stack_depth / sizeof(t_CKUINT) ) + ( func->stack_depth & 0x3 ? 1 : 0 ); // UNUSED: get the previous stack depth - caller function args - // UNUSED: t_CKUINT prev_stack = ( *(mem_sp-1) >> 2 ) + ( *(mem_sp-1) & 0x3 ? 1 : 0 ); + // UNUSED: t_CKUINT prev_stack = ( *(mem_sp-1) / sizeof(t_CKUINT) ) + ( *(mem_sp-1) & 0x3 ? 1 : 0 ); // the amount to push in 4-byte words t_CKUINT push = local_depth; // push the mem stack passed the current function variables and arguments @@ -2704,11 +2704,11 @@ // get the local stack depth - caller local variables t_CKUINT local_depth = *(reg_sp+1); // convert to number of 4-byte words, extra partial word counts as additional word - local_depth = ( local_depth >> 2 ) + ( local_depth & 0x3 ? 1 : 0 ); + local_depth = ( local_depth / sizeof(t_CKUINT) ) + ( local_depth & 0x3 ? 1 : 0 ); // get the stack depth of the callee function args - t_CKUINT stack_depth = ( func->stack_depth >> 2 ) + ( func->stack_depth & 0x3 ? 1 : 0 ); + t_CKUINT stack_depth = ( func->stack_depth / sizeof(t_CKUINT) ) + ( func->stack_depth & 0x3 ? 1 : 0 ); // UNUSED: get the previous stack depth - caller function args - // UNUSED: t_CKUINT prev_stack = ( *(mem_sp-1) >> 2 ) + ( *(mem_sp-1) & 0x3 ? 1 : 0 ); + // UNUSED: t_CKUINT prev_stack = ( *(mem_sp-1) / sizeof(t_CKUINT) ) + ( *(mem_sp-1) & 0x3 ? 1 : 0 ); // the amount to push in 4-byte words t_CKUINT push = local_depth; // push the mem stack passed the current function variables and arguments