Replies: 6 comments
-
Those were changed from local variables to stack-allocated pointers in 93u+ 2011-12-24. See the xec.c changes in ksh93/ksh93-history@1ce26c0. It's always more or less guesswork with so many changes per commit in ksh93-history, but I'm pretty sure this is the corresponding
Using a local variable for the context/longjmp buffer is perfectly legit and functional, but does use …which is currently defined in path.h as |
Beta Was this translation helpful? Give feedback.
-
You might also wonder why they used the AST stack (via stkallocl/stakalloc) instead of the heap. The answer is efficiency. The stack gets allocated on the heap in chunks of |
Beta Was this translation helpful? Give feedback.
-
Hum, head scratching :) I understand the stakalloc on malloc, I understand that ksh 'stack' (ksh function, scope, etc) is not C stack, I understand as well that a stack implemented on top of malloc (or mmap) would allow multiple alloc, single free at ksh level, i.e scope locals are allocated one by one and freed once on unscope (may be didn't checked that), exatly as What's bugs me is that a Well anyway I got the picture now, let's assume ASAN will catch such dangling jump buffer :) Tahnx @McDutchie for your explanations always usefull :) |
Beta Was this translation helpful? Give feedback.
-
The central execution function sh_exec() stores the current stack offset as a local variable on every recursive invocation and restores it at the end (unless a loop invariants optimisation is in use). Even if multiple levels of jmpval occur, the stack should not be truncated to before the current jmpval buffer because jmpval restores the local variable environment. So, as long as the state is restored correctly before executing sigjmpval, how is that more dangerous than any other approach? |
Beta Was this translation helpful? Give feedback.
-
Speaking of which... ksh/src/cmd/ksh93/features/setjmp Lines 1 to 18 in d446015 The header generated by this feature test script (see arch/*/src/cmd/ksh93/FEATURE/setjmp) is included by every ksh93 .c file via edit.h and fault.h. If the system has suppresses a massive rant about AT&T code quality standards, yet again Presumably there is a missing After removing it, |
Beta Was this translation helpful? Give feedback.
-
Ha ok, good enough, I now understand why we can stakalloc a checkpoint :) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Gurus,
I have hard time to understand the logic of statement like
checkpoint = (struct checkpt*)stakalloc(sizeof(struct checkpt));
As I understand it, the
checkpoint->buff
will host ssigsetjmp
buffer, meaning (with my understanding) that later on asiglongjmp
will land there (at the same function as thesigsetjmp
call site) so why not stuffcheckpoint
as an local var as in many other spots in the source tree. IS there some magic there I should know?Thanx in advance
Beta Was this translation helpful? Give feedback.
All reactions