Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve yieldto error handling #21458

Merged
merged 3 commits into from
Apr 23, 2017
Merged

improve yieldto error handling #21458

merged 3 commits into from
Apr 23, 2017

Conversation

vtjnash
Copy link
Sponsor Member

@vtjnash vtjnash commented Apr 20, 2017

previously we couldn't reliably tell the difference between a failure to context switch
and an explicitly scheduled error

in the former case, we often need to undo some prior action
by moving the code for the later into Julia,
we can reliably run the necessary undo action when required

fix #21442

base/event.jl Outdated
@@ -150,19 +150,64 @@ tasks.
yield() = (enq_work(current_task()); wait())

"""
yield(t::Task, arg = nothing)

A fast, unfair-scheduling version of "schedule(t, arg); yield()" which
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be code highlighted rather than " quoted?

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it? I feel like I've been told I'm wrong whichever way I choose.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

" quotes are for strings in code, not so much code in docstrings

base/event.jl Outdated
yield(t::Task, arg = nothing)

A fast, unfair-scheduling version of `schedule(t, arg); yield()` which
immediately yields to "t" before calling the scheduler.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

t should also use backticks

previously we couldn't reliably tell the difference between a failure to context switch
and an explicitly scheduled error

in the former case, we often need to undo some prior action
by moving the code for the later into Julia,
we can reliably run the necessary undo action when required

fix #21442
return try_yieldto(Void, t)
end

function try_yieldto(undo::F, t::Task) where F
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is F needed at all?

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it ensures that this gets a specialized call site

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe worth noting that with a comment so it doesn't accidentally get removed

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would an accident like that happen? Just think of this as the opposite of ::ANY (which we also don't need comments on).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it cause a test failure if removed? it looks unnecessary, is it documented that this forces specialization and when that's necessary?

Copy link
Sponsor Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I said, it's like ::ANY – it will never cause a tests failure, it's generally unnecessary, and nobody would probably notice

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and, like ::ANY it could really use comments when it's doing something important

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @tkelman is right here. There are a lot of type signatures that end up having unnecessary type parameters for various reasons, which we tend to reflexively remove. ANY only gets used for a reason, which we don't reflexively use. So unless you comment this or test it somehow, you should expect that this will get deleted at some point.

base/stream.jl Outdated
@@ -794,7 +794,7 @@ uv_write(s::LibuvStream, p::Vector{UInt8}) = uv_write(s, pointer(p), UInt(sizeof
function uv_write(s::LibuvStream, p::Ptr{UInt8}, n::UInt)
check_open(s)
uvw = Libc.malloc(_sizeof_uv_write)
uv_req_set_data(uvw,C_NULL)
uv_req_set_data(uvw, C_NULL) # in-case we get interrupted before arriving at the wait call
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in case, space not dash

@vtjnash vtjnash merged commit 57bcefb into master Apr 23, 2017
@vtjnash vtjnash deleted the jn/yieldto-error branch April 23, 2017 13:20
@tkelman
Copy link
Contributor

tkelman commented Apr 25, 2017

This broke multiple packages, anything that was relying on the deprecation of produce/consume. Ex: https://github.com/JuliaCI/pkg.julialang.org/blob/64fea61d49dc90d55b5456b77afdbbc17e132a6c/logs/Erdos_0.6.log

# fast version of schedule(t,v);wait()
function schedule_and_wait(t::Task, v=nothing)
# fast version of `schedule(t, arg); wait()`
function schedule_and_wait(t::Task, arg=nothing)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

v=nothing or change v to arg in the body.

And a test for schedule_and_wait

vtjnash added a commit that referenced this pull request Apr 25, 2017
ensure that Windows libc stdio is also redirected by redirect_stdio,
since jl_safe_printf is using the msvcrt-compatibility library
rather than directly using the Win32 API

fix issue mentioned in #21458
@sbromberger
Copy link
Contributor

sbromberger commented Apr 26, 2017

ref andrewcooke/ParserCombinator.jl#24 (which breaks GraphIO and LightGraphs v0.8). (Same issue as Erdos.)

StefanKarpinski pushed a commit that referenced this pull request Apr 26, 2017
* Improve code-coverage testing of event scheduler so that we would have caught this breakage in CI
* Ensure that Windows libc stdio is also redirected by redirect_stdio, since jl_safe_printf is using the msvcrt-compatibility library rather than directly using the Win32 API
* Stop leaking a handle to the current process to child processes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash when using IO from finalizer inside Task
5 participants