-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 03/06/10 17:24, David Given wrote:
[...]
> It's crashing --- I think --- because the stub routine's own stack usage
> is overwriting vfork()'s caller's stack, since n is quite small. If my
> analysis is correct it ought to be easily fixable by telling the stub
> not to overwrite the stack.
The attached trivial patch does exactly this, and everything now works fine.
(Although init's calling execl() now fails later, but that's due to an
honest emulation bug and therefore Another Story.)
Any comments welcome --- if this *is* a Prex bug, I don't know why other
platforms aren't running into it, but if it's a bug in my BSP code, it's
one based on my understanding of how the stack handling works and
therefore not subject to analysis by code inspection.
diff --git a/usr/lib/posix/process/fork_nommu.c
b/usr/lib/posix/process/fork_nommu.c
index d69800d..c48eb6d 100755
- --- a/usr/lib/posix/process/fork_nommu.c
+++ b/usr/lib/posix/process/fork_nommu.c
@@ -88,6 +88,7 @@ vfork(void)
task_t tsk;
thread_t t;
int error, sts, pri;
+ char stubstack[256];
/* Save current stack pointer */
sts = setjmp(__fork_env);
@@ -130,7 +131,7 @@ vfork(void)
* the child's priority to lower value. This ugly hack
* will be replaced by some other methods...
*/
- - thread_load(t, __child_entry, NULL);
+ thread_load(t, __child_entry, stubstack);
thread_getpri(t, &pri);
thread_setpri(t, pri + 1);
thread_resume(t);
@@ -145,7 +146,7 @@ vfork(void)
/*
* Child task
*/
- - thread_load(__parent_thread, __parent_entry, NULL);
+ thread_load(__parent_thread, __parent_entry, stubstack);
t = thread_self();
thread_getpri(t, &pri);
thread_setpri(t, pri - 1);
- - --
┌─── dg@cowlark.com ───── http://www.cowlark.com ─────
│
│ life←{ ↑1 ⍵∨.^3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵ }
│ --- Conway's Game Of Life, in one line of APL
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkwI4NEACgkQf9E0noFvlzhdWwCfYlPZhEjBp/W7W3d1vybeegvl
5HwAnR/h3w2ZcMnaehwT2iXJBGu6l7h6
=lRf5
-----END PGP SIGNATURE-----
------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit. See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Prex-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/prex-devel