julia icon indicating copy to clipboard operation
julia copied to clipboard

don't throw EOFError from sleep

Open stevengj opened this issue 1 year ago • 6 comments

This prevents sleep from throwing an EOFError under rare conditions (with very short timer durations) where the Timer object is already closed before it can be signaled, which seems like a bug.

See the discourse discussion.

stevengj avatar Jun 14 '24 13:06 stevengj

why isn't this a correct fix?

oscardssmith avatar Jun 14 '24 14:06 oscardssmith

It seems like a better fix would make wait(Timer(sec)) safe, somehow.

Timer is an exported API, so ideally calling wait on a newly created Timer should not be a dangerous pattern.

stevengj avatar Jun 17 '24 00:06 stevengj

Yes, that is what is wrong about this fix. The wait tries to do some fast paths before locking, but it doesn't implement those correctly, and it doesn't re-check if it is .set after !isopen

vtjnash avatar Jun 17 '24 01:06 vtjnash

https://github.com/JuliaLang/julia/blob/222231f047462bcb2cef3e402c86cf41df82414d/base/asyncevent.jl#L159

Why is there an error throw anyways?

A1-Mathematik avatar Jun 21 '24 12:06 A1-Mathematik

@vtjnash and @stevengj I went through the code a couple of times but don't feel confident to fix this. Can you help me a little to fix it proper

lgeissbauer-btig avatar Jun 27 '24 09:06 lgeissbauer-btig

This should fix it https://github.com/JuliaLang/julia/pull/54955

lgeissbauer-btig avatar Jun 27 '24 13:06 lgeissbauer-btig

This should be closed because https://github.com/JuliaLang/julia/pull/54955 is merge

lgeissbauer-btig avatar Jul 18 '24 07:07 lgeissbauer-btig