[M3devel] Fwd: Re: Fwd: Fork bug
Daniel Alejandro Benavides Diaz
danielal.benavides at bancoagrario.gov.co
Fri Jul 11 00:31:59 CEST 2014
Hi:
I don't think so, that's precisely why the locking level notation was invented by Trestle' authors to cope with that complexity in the code, this allowed Trestle to be highly efficient for multiprocessors machines (among other things we need to look again for readers and writers efficiency). These two pieces of software were ESCed by Nelson and others. In that side Nelson said about this was a mistake in Java programming language design, because of the difficulty of reasoning about concurrency properties as seen in ESC experiments. If I may say add, Algol like languages excel in intelligibility, something other language families didn't make too much effort to support.
In any case, I'm not for this change so don't make me do a second attempt to return to this forum :)
Thanks in advance
-----Mensaje original-----
De: Rodney M. Bates [mailto:rodney_bates at lcwb.coop]
Enviado el: Martes, 08 de Julio de 2014 02:20 p.m.
Para: m3devel
Asunto: [M3devel] Fwd: Re: Fwd: Fork bug
Resent after 24 hours:
While we are working on MUTEX, I would like to propose making them what I believe is meant by a recursive mutex, that is, one thread can lock multiple times, the mutex being released only when the number of unlocks catches up with the number of locks.
I don't remember the details off the top of my head, but there is a place in Trestle where you have to acquire a MUTEX but it is very difficult or impossible to know whether different code on the same thread already has done so. The different code isn't under your control either. Some runtime scheme to figure it out dynamically would be tantamount to, but messier than, just having a recursive MUTEX.
I recall there are other places as well where similar problems arise.
It would greatly simplify things when needed.
The only disadvantage I can think of is there might be a case where runtime detection of a second lock attempt by the same thread would help find a bug. Maybe the RTS could have a way of setting the behavior of a specific MUTEX.
On 07/03/2014 02:28 PM, Tony Hosking wrote:
> I wonder if we should not move to a surrogate parent model to make this cleaner in general?
> Since fork is (or should be) only used in service of creating a new process (i.e., fork + exec) then this technique would save us a lot of grief.
> Thoughts?
>
> In the surrogate parent model, a program forks a child process at initialization time. The sole purpose of the child is to serve as a sort of "surrogate parent" for the original process should it ever need to fork another child. After initialization, the original parent can proceed to create its additional threads. When it wants to /exec/ an image, it communicates this to its child (which has remained single-threaded). The child then performs the /fork/ and /exec/ on behalf of the original process.
>
>
>
> Begin forwarded message:
>
>> *From: *Peter McKinna <peter.mckinna at gmail.com
>> <mailto:peter.mckinna at gmail.com>>
>> *Subject: **Fork bug*
>> *Date: *July 2, 2014 at 10:30:24 PM EDT
>> *To: *Antony Hosking <hosking at cs.purdue.edu
>> <mailto:hosking at cs.purdue.edu>>
>>
>> Hi Tony,
>>
>> That fork bug on posix doesn't appear to be fixed, so just to recap the problem. In the threadtest program if you have a bunch of threads creating mutexes and having them collected then get a thread that does a few forks what can happen is that the child executes atforkchild as I think the first thing it does which calls initwithstackbase which does an allocation and possible collection. Unfortunately the weaktable from the parent may be non empty and this is the only thread executing. It calls the cleanup of those mutexes of nonexistant threads some of which may be locked. If they are locked then pthread_mutex_destroy returns ebusy. Then the child exits with the abort in pthread_mutex_delete.
>> Whether the abort is needed I dont know. In this case the error can be safely ignored. One could try to see if the owner of the mutex is still alive and not abort in that case. Otherwise if one is sure the child is going to do an exec almost immediately then disabling the collector in atforkchild could work.
>> In the broader picture anything thats got a weak ref still active could cause problems if one thread does a fork. The weak callback could do anything.
>> Anyway I dont know what the fix is.
>>
>> Peter
>
--
Rodney Bates
rodney.m.bates at acm.org<mailto:rodney.m.bates at acm.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20140710/652fdffe/attachment-0002.html>
More information about the M3devel
mailing list