Closed GoogleCodeExporter closed 8 years ago
The problem above is caused by an illegal invocation of the ELVirtualMachine
thread (which invokes the
when:disconnected: event handler) on the actor mirror. Because the actor mirror
in this case is replaced using
reflection (in the FuturesModule), the actor mirror is a Coercer and the
illegal access was trapped.
Cause: the method Evaluator.trigger can be invoked by non-actor threads and may
directly call methods like
closure.meta_receive or actor.acceptSelfSend, which then calls
mirror.base_schedule. Since meta_receive and
base_schedule may be overridden using reflection, they can execute arbitrary
AmbientTalk code that should
be serialized in the owner actor!
The Evaluator.trigger method should instead schedule the call to
actor.acceptSelfSend to be performed by the
actor itself.
I still have to figure out what the effect of this change will be on the
overall interpreter.
Original comment by tvcut...@gmail.com
on 25 Oct 2009 at 8:39
Fixed in interpreter/trunk r1634
The bug was related to the method Evaluator.trigger, which can be invoked by
any thread (not only actor
threads) to send an 'apply' message to a closure owned by another actor.
Unfortunately, Evaluator.trigger
directly invoked actor.acceptSelfSend(...), which in turn invokes
mirror.base_schedule(...), meaning that an
external thread could actually concurrently manipulate another actor's inbox!
The solution was to add a new
event, event_trigger, to the public interface of an actor: other threads may
signal this event if they want the
actor to perform the asynchronous self-send.
An example where the bug would manifest itself is included in
at/unit/bugfixes.at , which now, of course,
passes without problems.
How could this bug manifest in the first place? I think because in the
implementation, non-actor threads like
ELFarReference event loops, ELVirtualMachine event loops etc. received direct
Java references to the
subscribing closures. This enables them to invoke apply on these closures
without the interpreter being able
to catch the bug. Actually, the bug was discovered by Ben because he had set
enableFutures(true), which
causes the actor's mirror to be replaced by a custom one. At the
implementation-level, this means the actor's
mirror is actually a coercer (of type ATActorMirror), and coercers *do* trap
illegal method invocations. It was
thanks to this trap that I could discover the bug.
Original comment by tvcut...@gmail.com
on 10 Nov 2009 at 3:58
Original issue reported on code.google.com by
tvcut...@gmail.com
on 25 Oct 2009 at 8:34