Issue 1:
I have some code that deadlocks, I think during some phase of code generation. Here's a little test case. Not quite the same context as my code, but I think the same bug:

Threads.@threads for i in 1:1
end
no_such_function()

This should give an error of course, because no_such_function is undefined. That's what it does on julia 1.1 regardless of the number of threads, but it deadlocks for me on master if >1 threads are specified. I ran a bisect which implicated this commit 0136fa1

Issue 2:
Totally confused by the segmentation fault I'm getting on dev branch. Started seeing it perhaps a couple weeks back but had a hard time getting a small test case that would reliably trigger the error.

The following snippet works fine if threads are off and works v1.1 with threads on or off. For some reason importing PyCall seems important but I have no idea why (BTW: I have PyCall v1.91.2).

Can anybody else reproduce this?

Threads.nthreads() # <-- 4
import PyCall
abstract type Flat end
struct X{P<:Flat, T<:Real}
t::Array{T,1}
end
function foo(x::X{P,T}) where {P<:Flat, T<:Real}
v = zeros(T, size(x.t))
Threads.@threads for i=1:length(x.t)
v[i] = x.t[i]^2 + sin(x.t[i]) - cos(x.t[i])
end
return v
end
T = Float64
x = X{Flat,T}(rand(T,1000))
@time foo(x) #<--- Segmentation fault

Here is the error I get

julia> @time foo(x) #<--- Segmentation fault

fatal: error thrown and no exception handler available.
ErrorException("concurrency violation detected")
0.203108rec_backtrace at /Users/ethananderes/Software/juliaMaster/src/stackwalk.c:94
record_backtrace at /Users/ethananderes/Software/juliaMaster/src/task.c:210
jl_throw at /Users/ethananderes/Software/juliaMaster/src/task.c:417
seconds (error at ./error.jl:33
assert_havelock at ./condition.jl:20 [inlined]
assert_havelock at ./condition.jl:43 [inlined]
assert_havelock at ./condition.jl:67 [inlined]
notify at ./condition.jl:118
#notify#463 at ./condition.jl:116 [inlined]
notify at ./condition.jl:116 [inlined]
notify at ./condition.jl:116 [inlined]
readcb_specialized at ./stream.jl:558
jfptr_readcb_specialized_4955 at /Users/ethananderes/Software/juliaMaster/usr/lib/julia/sys.dylib (unknown line)
528.70uv_readcb at ./stream.jl:599
kunknown function (ip: 0x1119208a4)
allocations: 26.948 MiB, 3.00% gc time)jlcapi_uv_readcb_4173_gfthunk at /Users/ethananderes/Software/juliaMaster/usr/lib/julia/sys.dylib (unknown line)
jlcapi_uv_readcb_4173 at /Users/ethananderes/Software/juliaMaster/usr/lib/julia/sys.dylib (unknown line)

uv__read at /workspace/srcdir/libuv/src/unix/stream.c:1179
uv__stream_io at /workspace/srcdir/libuv/src/unix/stream.c:1339
uv__io_poll at /workspace/srcdir/libuv/src/unix/kqueue.c:311
uv_run at /workspace/srcdir/libuv/src/unix/core.c:361
jl_task_get_next at /Users/ethananderes/Software/juliaMaster/src/partr.c:303
poptaskref at ./task.jl:564
wait at ./task.jl:591
task_done_hook at ./task.jl:327
jl_apply at /Users/ethananderes/Software/juliaMaster/src/./julia.h:1604 [inlined]
jl_finish_task at /Users/ethananderes/Software/juliaMaster/src/task.c:167
start_task at /Users/ethananderes/Software/juliaMaster/src/task.c:593
1000-element Array{Float64,1}:

signal (11): Segmentation fault: 11
in expression starting at REPL[8]:0
Segmentation fault: 11

julia> versioninfo()
Julia Version 1.3.0-DEV.8
Commit 20834c3176* (2019-04-12 07:18 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin18.5.0)
CPU: Intel(R) Core(TM) i7-8559U CPU @ 2.70GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-6.0.1 (ORCJIT, skylake)
Environment:
JULIA_NUM_THREADS = 4
JULIA_FFTW_PROVIDER = MKL