[Opa] UserContext and shooting myself in the foot (hangs)
rudy.sicard at mlstate.com
Wed Jan 25 11:23:18 UTC 2012
We are thinking of using simple schemes based on timeout to detect *at
runtime* this kind of dead locks in order to provide helpful message.
Until we decide to use these schemes by default you can "protect"
your-self with something like that:
@expand // keep position of the call site
f = Scheduler.make_timeoutable(
10000 // timeout in ms
-> do println("UserContext_execute : I shooted my self in
the foot, but I can look at the assert failure position !"); @assert(false)
and the use UserContext_execute instead of UserContext.execute.
If something goes wrong the assertion failure will give you the position
of the call UserContext_execute that is the victim of the dead lock
(i.e. no the guilty inner call).
On 25/01/2012 02:53, Owen Gunden wrote:
> I just noticed that opaDo keeps the usercontext inside the User module
> as global state. I think adopting that model will largely solve my
> issues as they are related to threading the usercontext through all my
> function calls.
> I'm still interested if anyone has thoughts on a way to make this
> mistake more difficult to do by accident.
> On Tue, Jan 24, 2012 at 4:41 PM, Owen Gunden<ogunden at phauna.org> wrote:
>> I keep accidentally shooting myself in the foot with
>> UserContext.execute. I write something like this:
>> f(uc) =
>> UserContext.execute( (uc_state ->
>> // do some stuff..
>> // la la la..
>> ), uc)
>> some_function(uc) =
>> // do more stuff..
>> UserContext.execute( (uc_state -> ...), uc)
>> And then my program hangs forever when I call f. I think calls to
>> UserContext.execute from within itself lead to a deadlock. I don't
>> think I ever actually *need* to do this, I just do it by accident a
>> Any pointers on avoiding this situation? I was thinking that since
>> *most* of the time I only need to read the usercontext, not write it,
>> I could define a function get_usercontext_state(uc) =
>> UserContext.execute(x -> x, uc) and use that instead of execute most
>> of the time. I just wonder if there isn't a sexier type-system way to
>> make this safer?
> Opa mailing list
> Opa at lists.owasp.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Opa