I was debugging the problem with exit crashing in dash and found that this is happening because the setjmp buffers are getting corrupt because the buffers are allocated from the call stack itself. Here is what I found. There are 3 consecutive setjmp calls made before the first call to longjmp. The 2nd and 3rd setjmp calls are made from two different functions (redirectsafe and evalbltin) both of which are called from evalcommand. Since the buffer is made available from the call stack, when the call returns the stack is unwound and then again another call is made the stack is used up, the buffer is corrupted. Dont know if there are fixes for this..or I am missing somthing really subtle. Here is the info: 1st setjmp from main: ------------------------------------ Breakpoint 2, 0x0000000000410720 in setjmp () (gdb) backtrace #0 0x0000000000410720 in setjmp () #1 0x000000000040010c in main () (gdb) info registers x0 0x7ffffffb30 549755812656 x1 0x7ffffffc88 549755813000 x2 0x7ffffffc98 549755813016 x3 0x4060 16480 x4 0x424200 4342272 x5 0x424200 4342272 x6 0x3e80 16000 x7 0x1 1 x8 0x1d 29 x9 0x0 0 x10 0x0 0 x11 0x0 0 x12 0x0 0 x13 0x0 0 x14 0x0 0 x15 0x0 0 x16 0x0 0 x17 0x0 0 x18 0x0 0 x19 0x1 1 x20 0x0 0 x21 0x0 0 x22 0x0 0 x23 0x0 0 x24 0x0 0 x25 0x0 0 x26 0x0 0 x27 0x0 0 x28 0x0 0 x29 0x7ffffffb10 549755812624 x30 0x40010c 4194572 sp 0x7ffffffb10 0x7ffffffb10 pc 0x410720 0x410720 cpsr 0x20000000 536870912 fpsr 0x0 0 fpcr 0x0 0 (gdb) (gdb) disassem Dump of assembler code for function main: 0x00000000004000ec <+0>: stp x29, x30, [sp,#-320]! 0x00000000004000f0 <+4>: mov x29, sp 0x00000000004000f4 <+8>: str w0, [x29,#304] 0x00000000004000f8 <+12>: add x0, x29, #0x20 0x00000000004000fc <+16>: str x19, [sp,#16] 0x0000000000400100 <+20>: str x1, [x29,#312] 0x0000000000400104 <+24>: str wzr, [x29,#296] 0x0000000000400108 <+28>: bl 0x410720 => 0x000000000040010c <+32>: cbz w0, 0x4001a0 0x0000000000400110 <+36>: bl 0x40e47c 0x0000000000400114 <+40>: adrp x0, 0x424000 0x0000000000400118 <+44>: ldr w0, [x0,#2520] 0x000000000040011c <+48>: ldr w19, [x29,#296] 0x0000000000400120 <+52>: cmp w0, #0x4 0x0000000000400124 <+56>: b.eq 0x400144 0x0000000000400128 <+60>: cbz w19, 0x400144 0x000000000040012c <+64>: adrp x1, 0x428000 0x0000000000400130 <+68>: ldrb w1, [x1,#3227] 0x0000000000400134 <+72>: cbz w1, 0x400144 0x0000000000400138 <+76>: adrp x1, 0x428000 0x000000000040013c <+80>: ldr w1, [x1,#2692] 0x0000000000400140 <+84>: cbz w1, 0x400148 ---Type to continue, or q to quit---q Quit (gdb) x/30g 0x7ffffffb30 0x7ffffffb30: 29 0 0x7ffffffb40: 0 0 0x7ffffffb50: 0 0 0x7ffffffb60: 0 0 0x7ffffffb70: 0 0 0x7ffffffb80: 1 0 0x7ffffffb90: 0 0 0x7ffffffba0: 0 0 0x7ffffffbb0: 0 0 0x7ffffffbc0: 0 0 0x7ffffffbd0: 549755812624 4194572 0x7ffffffbe0: 0 0 0x7ffffffbf0: 0 0 0x7ffffffc00: 0 0 0x7ffffffc10: 0 0 (gdb) ---------------------------------------------------------------------------------- User Actions: ------------------- Prompt appears Exit command entered ---------------------------------------------------------------------------------- 2nd Call to setjmp ---------------------------------------------------------------------------------- Breakpoint 2, 0x0000000000410720 in setjmp () (gdb) backtrace #0 0x0000000000410720 in setjmp () #1 0x000000000040b71c in redirectsafe () #2 0x000000000040286c in evalcommand () #3 0x0000000000401c04 in evaltree () #4 0x0000000000407830 in cmdloop () #5 0x000000000040019c in main () (gdb) info registers x0 0x7ffffff880 549755811968 x1 0x3 3 x2 0x428000 4358144 x3 0x1 1 x4 0x74 116 x5 0x424200 4342272 x6 0x3a00 14848 x7 0x1 1 x8 0x3f 63 x9 0x5 5 x10 0x411053 4264019 x11 0x4241ea 4342250 x12 0x0 0 x13 0x0 0 x14 0x0 0 x15 0x0 0 x16 0x5 5 x17 0x0 0 x18 0x4127c8 4270024 x19 0x0 0 x20 0x1 1 x21 0x428ab8 4360888 x22 0x428af8 4360952 x23 0x1 1 x24 0x0 0 x25 0x424298 4342424 x26 0x7ffffffa18 549755812376 x27 0x428ad8 4360920 x28 0x0 0 x29 0x7ffffff860 549755811936 x30 0x40b71c 4241180 sp 0x7ffffff860 0x7ffffff860 pc 0x410720 0x410720 cpsr 0x20000000 536870912 fpsr 0x0 0 fpcr 0x0 0 (gdb) 0x000000000040b71c in redirectsafe () (gdb) disassem Dump of assembler code for function redirectsafe: 0x000000000040b6e8 <+0>: stp x29, x30, [sp,#-304]! 0x000000000040b6ec <+4>: mov x29, sp 0x000000000040b6f0 <+8>: str x0, [x29,#288] 0x000000000040b6f4 <+12>: adrp x0, 0x424000 0x000000000040b6f8 <+16>: ldr x0, [x0,#2512] 0x000000000040b6fc <+20>: str x19, [sp,#16] 0x000000000040b700 <+24>: str x0, [x29,#272] 0x000000000040b704 <+28>: adrp x0, 0x424000 0x000000000040b708 <+32>: ldr w0, [x0,#2504] 0x000000000040b70c <+36>: str w1, [x29,#296] 0x000000000040b710 <+40>: str w0, [x29,#280] 0x000000000040b714 <+44>: add x0, x29, #0x20 0x000000000040b718 <+48>: bl 0x410720 => 0x000000000040b71c <+52>: lsl w19, w0, #1 0x000000000040b720 <+56>: cbnz w19, 0x40b73c 0x000000000040b724 <+60>: adrp x0, 0x424000 0x000000000040b728 <+64>: add x1, x29, #0x20 0x000000000040b72c <+68>: str x1, [x0,#2512] 0x000000000040b730 <+72>: ldr x0, [x29,#288] 0x000000000040b734 <+76>: ldr w1, [x29,#296] 0x000000000040b738 <+80>: bl 0x40b314 0x000000000040b73c <+84>: ldr x0, [x29,#272] ---Type to continue, or q to quit---q Quit (gdb) x/30g 0x7ffffff880 0x7ffffff880: 63 5 0x7ffffff890: 4264019 4342250 0x7ffffff8a0: 0 0 0x7ffffff8b0: 0 0 0x7ffffff8c0: 0 4270024 0x7ffffff8d0: 0 1 0x7ffffff8e0: 4360888 4360952 0x7ffffff8f0: 1 0 0x7ffffff900: 4342424 549755812376 0x7ffffff910: 4360920 0 0x7ffffff920: 549755811936 4241180 0x7ffffff930: 0 0 0x7ffffff940: 0 0 0x7ffffff950: 0 0 0x7ffffff960: 0 0 (gdb) ------------------------------------------------------------------------ 3rd call to setjmp ------------------------------------------------------------------------ Breakpoint 2, 0x0000000000410720 in setjmp () (gdb) backtrace #0 0x0000000000410720 in setjmp () #1 0x0000000000402594 in evalbltin () #2 0x0000000000402c20 in evalcommand () #3 0x0000000000401c04 in evaltree () #4 0x0000000000407830 in cmdloop () #5 0x000000000040019c in main () (gdb) info registers x0 0x7ffffff870 549755811952 x1 0x1 1 x2 0x428af8 4360952 x3 0x0 0 x4 0x600 1536 x5 0x5ff 1535 x6 0xa3f 2623 x7 0x411000 4263936 x8 0x411d55 4267349 x9 0x5 5 x10 0x411053 4264019 x11 0x4241ea 4342250 x12 0x0 0 x13 0x0 0 x14 0x0 0 x15 0x0 0 x16 0x5 5 x17 0x0 0 x18 0x4127c8 4270024 x19 0x1 1 x20 0x0 0 x21 0x428ab8 4360888 x22 0x428af8 4360952 x23 0x1 1 x24 0x0 0 x25 0x1 1 x26 0x411000 4263936 x27 0x428ad8 4360920 x28 0x0 0 x29 0x7ffffff830 549755811888 x30 0x402594 4203924 sp 0x7ffffff830 0x7ffffff830 pc 0x410720 0x410720 cpsr 0x60000000 1610612736 fpsr 0x0 0 fpcr 0x0 0 (gdb) 0x0000000000402594 in evalbltin () (gdb) disassem Dump of assembler code for function evalbltin: 0x0000000000402550 <+0>: stp x29, x30, [sp,#-352]! 0x0000000000402554 <+4>: mov x29, sp 0x0000000000402558 <+8>: str x0, [x29,#336] 0x000000000040255c <+12>: adrp x0, 0x424000 0x0000000000402560 <+16>: ldr x0, [x0,#2536] 0x0000000000402564 <+20>: stp x19, x20, [sp,#16] 0x0000000000402568 <+24>: str x0, [x29,#312] 0x000000000040256c <+28>: adrp x0, 0x424000 0x0000000000402570 <+32>: ldr x0, [x0,#2512] 0x0000000000402574 <+36>: stp x21, x22, [sp,#32] 0x0000000000402578 <+40>: str x0, [x29,#304] 0x000000000040257c <+44>: add x0, x29, #0x40 0x0000000000402580 <+48>: str x23, [sp,#48] 0x0000000000402584 <+52>: str w1, [x29,#328] 0x0000000000402588 <+56>: str x2, [x29,#320] 0x000000000040258c <+60>: str w3, [x29,#332] 0x0000000000402590 <+64>: bl 0x410720 => 0x0000000000402594 <+68>: mov w20, w0 0x0000000000402598 <+72>: cbnz w0, 0x4026c0 0x000000000040259c <+76>: adrp x0, 0x424000 0x00000000004025a0 <+80>: add x1, x29, #0x40 0x00000000004025a4 <+84>: str x1, [x0,#2512] ---Type to continue, or q to quit---q Quit (gdb) x/30g 0x7ffffff870 0x7ffffff870: 4267349 5 0x7ffffff880: 4264019 4342250 <-----------------------------------------at this point the buffer of the 2nd setjmp is corrupted 0x7ffffff890: 0 0 0x7ffffff8a0: 0 0 0x7ffffff8b0: 0 4270024 0x7ffffff8c0: 1 0 0x7ffffff8d0: 4360888 4360952 0x7ffffff8e0: 1 0 0x7ffffff8f0: 1 4263936 0x7ffffff900: 4360920 0 0x7ffffff910: 549755811888 4203924 0x7ffffff920: 0 0 0x7ffffff930: 0 0 0x7ffffff940: 0 0 0x7ffffff950: 0 0 0x7ffffff960: 549755811888 0 0x7ffffff970: 4360952 1 0x7ffffff980: 4267824 4263936 0x7ffffff990: 549755812464 4201476 0x7ffffff9a0: 4360888 0 0x7ffffff9b0: 4341760 0 0x7ffffff9c0: 4358144 4361368 0x7ffffff9d0: 4360828 4361488 0x7ffffff9e0: 0 0 0x7ffffff9f0: 4360840 4360920 0x7ffffffa00: 432 2 0x7ffffffa10: 4267824 0 0x7ffffffa20: 549755812376 4360928 0x7ffffffa30: 4360928 4224972 0x7ffffffa40: 0 0 (gdb) x/30g 0x7ffffffb30 <--------------------------------------the buffer of the first setjmp is intact 0x7ffffffb30: 29 0 0x7ffffffb40: 0 0 0x7ffffffb50: 0 0 0x7ffffffb60: 0 0 0x7ffffffb70: 0 0 0x7ffffffb80: 1 0 0x7ffffffb90: 0 0 0x7ffffffba0: 0 0 0x7ffffffbb0: 0 0 0x7ffffffbc0: 0 0 0x7ffffffbd0: 549755812624 4194572 0x7ffffffbe0: 0 0 0x7ffffffbf0: 0 0 0x7ffffffc00: 0 0 0x7ffffffc10: 0 0 (gdb) If someone knows about this problem please let me know.