> I've just stumbled on the follwoing problem with ucLinux
> Lets say task A does:
> if (!vfork())
> execlp fails....
> the code doing the system call will try to store the error code into
> the errno variable
> (well actiually the errno is defined as *get_errno_addr())
> but this varible is sitting in the data segment of the parent task!!!!
Well, since the vfork did _not_ fail, the parent code should ignore the
contents of errno. This is actually ok, errno is intended to contain the
last error, the worst that happens here is the last error code from the
parent thread is corrupted (who cares).
That having been said, this shows one of the issues one has to be careful
of when using vfork(). errno is not the only thing that the child can
corrupt, if you mess with anything in the child thread before you exec
_or_ after exec() fails, the parent finds it changed as well. Note that
this behaviour is exactly what one expects from vfork(). In order to
deal with the race condition that results, vfork() causes the parent
to sleep until the child does exec() or exit().
This is an interesting idea you have below (2 I mean). If we did something
like that, we would make a syscall that returns the pointer to a per task
area. That way there is nothing to fix up in the binfmt_flat loader. It
is also platform independant, which is a good thing. Multi threaded uC-libc
would be a good enough reason to do such a thing, but I'd still like to see
a pure user space solution (but none comes immediately to mind of course).
> 2.1 declare a private data block in the kernel task structure,
> char crtdata[CRTDATASIZE];
> 2.2 make following changets to crt0.s
> start: br next
> jmp 0
> 2.3 binfmt_flat loader will patch the jmp instruction with address
> of the kernel routine kernel_get_thread_data:
> void* kernel_get_thread_data()
> return current->crtdata;
> 2.4 get_errno_addr becomes
> int* get_errno_addr()
> (int*) get_thread_data();
> This appoach will eventually allow as to build a multi-threaded ucLibc....
> What do you think?
-- Cheers, Jeff / VE3DJF Jeff@RyeHam.ee.ryerson.ca http://www.cgocable.net/~jdionne
Got one, got one, everybody's got one. Oompah oompah, stick it up your jumper. Got one, got one, everybody's got one. Oompah oompah, stick it up your jumper. ... This message resent by the firstname.lastname@example.org list server http://www.uClinux.com/
This archive was generated by hypermail 2b30 : Sun Apr 07 2002 - 00:01:34 EST