small but important fix for clone2()
There is a longstanding and silly bug in clone2() which can lead to memory corruption. The problem is that when the user-stack area is specified explicitly (as is the case during pthread creation), clone2() failed to allocate the scratch space required by the calling convention. The patch below fixes this.
Thanks to Asit Mallick for tracking this down.
--david
ia64/kernel/process.c renamed from ia64/kernel/process.c~ +1 -1
@@ -267,7 +267,7 @@if (user_mode (child_ptregs)) {if (user_stack_base) { - child_ptregs->r12 = user_stack_base + user_stack_size; + child_ptregs->r12 = user_stack_base + user_stack_size -16 ; child_ptregs->ar_bspstore = user_stack_base; child_ptregs->ar_rnat =0 ; child_ptregs->loadrs =0 ;
Thursday's patch isn't sufficient. It breaks threaded ia32 apps. The patch below should be complete, but more testing needs to be done. At least the x86 version of OpenOffice works again.
--david
ia64/kernel/entry.S renamed from ia64/kernel/entry.S~ +1 -1
@@ -115,7 +115,7 @@ mov loc1=r16 // save ar.pfs across do_fork .body mov out1=in1 - mov out3=0 + mov out3 // stacksize (compensates for 16-byte scratch area) adds out2=IA64_SWITCH_STACK_SIZE+16,sp // out2 = ®s mov out0=in0 // out0 = clone_flags br.call.sptk.many rp=do_fork
ia64/ia32/ia32_entry.S renamed from ia64/ia32/ia32_entry.S~ +1 -1
@@ -37,7 +37,7 @@ mov loc1=r16 // save ar.pfs across do_fork .body zxt4 out1=in1 // newsp - mov out3=0 // stacksize + mov out3 // stacksize (compensates for 16-byte scratch area) adds out2=IA64_SWITCH_STACK_SIZE+16,sp // out2 = ®s zxt4 out0=in0 // out0 = clone_flags br.call.sptk.many rp=do_fork
ia64/kernel/process.c renamed from ia64/kernel/process.c~ +1 -1
@@ -267,7 +267,7 @@if (user_mode (child_ptregs)) {if (user_stack_base) { - child_ptregs->r12 = user_stack_base + user_stack_size; + child_ptregs->r12 = user_stack_base + user_stack_size -16 ; child_ptregs->ar_bspstore = user_stack_base; child_ptregs->ar_rnat =0 ; child_ptregs->loadrs =0 ;