JuliaLang / MbedTLS.jl

Wrapper around mbedtls
Other
41 stars 50 forks source link

`ssl_unsafe_read` requires `isreadable(::SSLContext)` #188

Closed omus closed 2 years ago

omus commented 5 years ago

An issue encountered on Julia 0.6.4 on MbedTLS 0.5.14:

ArgumentError: `ssl_unsafe_read` requires `isreadable(::SSLContext)`
ssl_unsafe_read(::MbedTLS.SSLContext, ::Ptr{UInt8}, ::UInt64) at /root/.julia/v0.6/MbedTLS/src/ssl.jl:298
readavailable at /root/.julia/v0.6/MbedTLS/src/ssl.jl:434 [inlined]
purge(::HTTP.ConnectionPool.Connection{MbedTLS.SSLContext}) at /root/.julia/v0.6/HTTP/src/ConnectionPool.jl:335
close(::HTTP.ConnectionPool.Connection{MbedTLS.SSLContext}) at /root/.julia/v0.6/HTTP/src/ConnectionPool.jl:321
close(::HTTP.ConnectionPool.Transaction{MbedTLS.SSLContext}) at /root/.julia/v0.6/HTTP/src/ConnectionPool.jl:308
#request#1(::Void, ::Type{T} where T, ::Array{Any,1}, ::Function, ::Type{HTTP.ConnectionRequest.ConnectionPoolLayer{HTTP.StreamRequest.StreamLayer}}, ::HTTP.URIs.URI, ::HTTP.Messages.Request, ::Array{UInt8,1}) at /root/.julia/v0.6/HTTP/src/ConnectionRequest.jl:49
(::HTTP.#kw##request)(::Array{Any,1}, ::HTTP.#request, ::Type{HTTP.ConnectionRequest.ConnectionPoolLayer{HTTP.StreamRequest.StreamLayer}}, ::HTTP.URIs.URI, ::HTTP.Messages.Request, ::Array{UInt8,1}) at ./<missing>:0
#request#1(::Array{Any,1}, ::Function, ::Type{HTTP.ExceptionRequest.ExceptionLayer{HTTP.ConnectionRequest.ConnectionPoolLayer{HTTP.StreamRequest.StreamLayer}}}, ::HTTP.URIs.URI, ::Vararg{Any,N} where N) at /root/.julia/v0.6/HTTP/src/ExceptionRequest.jl:19
(::HTTP.#kw##request)(::Array{Any,1}, ::HTTP.#request, ::Type{HTTP.ExceptionRequest.ExceptionLayer{HTTP.ConnectionRequest.ConnectionPoolLayer{HTTP.StreamRequest.StreamLayer}}}, ::HTTP.URIs.URI, ::HTTP.Messages.Request, ::Array{UInt8,1}) at ./<missing>:0
#request#1(::VersionNumber, ::String, ::Void, ::Void, ::Array{Any,1}, ::Function, ::Type{HTTP.MessageRequest.MessageLayer{HTTP.ExceptionRequest.ExceptionLayer{HTTP.ConnectionRequest.ConnectionPoolLayer{HTTP.StreamRequest.StreamLayer}}}}, ::String, ::HTTP.URIs.URI, ::Array{Pair{SubString{String},SubString{String}},1}, ::Array{UInt8,1}) at /root/.julia/v0.6/HTTP/src/MessageRequest.jl:45
(::HTTP.#kw##request)(::Array{Any,1}, ::HTTP.#request, ::Type{HTTP.MessageRequest.MessageLayer{HTTP.ExceptionRequest.ExceptionLayer{HTTP.ConnectionRequest.ConnectionPoolLayer{HTTP.StreamRequest.StreamLayer}}}}, ::String, ::HTTP.URIs.URI, ::Array{Pair{SubString{String},SubString{String}},1}, ::Array{UInt8,1}) at ./<missing>:0
macro expansion at /root/.julia/v0.6/AWSCore/src/http.jl:36 [inlined]
macro expansion at /root/.julia/v0.6/Retry/src/repeat_try.jl:206 [inlined]
http_request(::Dict{Symbol,Any}) at /root/.julia/v0.6/AWSCore/src/http.jl:20
macro expansion at /root/.julia/v0.6/AWSCore/src/AWSCore.jl:421 [inlined]
macro expansion at /root/.julia/v0.6/Retry/src/repeat_try.jl:206 [inlined]
do_request(::Dict{Symbol,Any}) at /root/.julia/v0.6/AWSCore/src/AWSCore.jl:399
macro expansion at /root/.julia/v0.6/AWSS3/src/AWSS3.jl:111 [inlined]
macro expansion at /root/.julia/v0.6/Retry/src/repeat_try.jl:206 [inlined]
#s3#1(::Dict{String,String}, ::SubString{String}, ::Dict{String,String}, ::String, ::Array{UInt8,1}, ::Bool, ::Bool, ::Function, ::Dict{Symbol,Any}, ::String, ::SubString{String}) at /root/.julia/v0.6/AWSS3/src/AWSS3.jl:81
(::AWSS3.#kw##s3)(::Array{Any,1}, ::AWSS3.#s3, ::Dict{Symbol,Any}, ::String, ::SubString{String}) at ./<missing>:0
#s3_put#27(::Dict{String,String}, ::Dict{String,String}, ::Function, ::Dict{Symbol,Any}, ::SubString{String}, ::SubString{String}, ::Array{UInt8,1}, ::String, ::String) at /root/.julia/v0.6/AWSS3/src/AWSS3.jl:659
s3_put(::Dict{Symbol,Any}, ::SubString{String}, ::SubString{String}, ::Array{UInt8,1}, ::String, ::String) at /root/.julia/v0.6/AWSS3/src/AWSS3.jl:627
...
Keno commented 4 years ago

https://github.com/JuliaWeb/HTTP.jl/pull/529 suppresses those errors during close

ararslan commented 2 years ago

I'm running into this with Julia 1.8.0, MbedTLS 1.1.5, HTTP 1.1.3, similarly by way of AWSS3 (0.10.0).

Unhandled Task ERROR: MbedTLS error code -80: NET - Connection was reset by peer
Stacktrace:
 [1] ssl_unsafe_read(ctx::MbedTLS.SSLContext, buf::Ptr{UInt8}, nbytes::UInt64)
   @ MbedTLS ~/.julia/packages/MbedTLS/4i6Lh/src/ssl.jl:376
 [2] wait_for_decrypted_data(ctx::MbedTLS.SSLContext)
   @ MbedTLS ~/.julia/packages/MbedTLS/4i6Lh/src/ssl.jl:312
 [3] eof(ctx::MbedTLS.SSLContext)
   @ MbedTLS ~/.julia/packages/MbedTLS/4i6Lh/src/ssl.jl:175
 [4] monitor_idle_connection(c::HTTP.ConnectionPool.Connection)
   @ HTTP.ConnectionPool ~/.julia/packages/HTTP/PesRN/src/ConnectionPool.jl:264
 [5] (::HTTP.ConnectionPool.var"#2#3"{HTTP.ConnectionPool.Connection})()
   @ HTTP.ConnectionPool ./task.jl:484
Unhandled Task ERROR: ArgumentError: `ssl_unsafe_read` requires `isreadable(::SSLContext)`
Stacktrace:
 [1] ssl_unsafe_read(ctx::MbedTLS.SSLContext, buf::Ptr{UInt8}, nbytes::UInt64)
   @ MbedTLS ~/.julia/packages/MbedTLS/4i6Lh/src/ssl.jl:345
 [2] wait_for_decrypted_data(ctx::MbedTLS.SSLContext)
   @ MbedTLS ~/.julia/packages/MbedTLS/4i6Lh/src/ssl.jl:312
 [3] eof(ctx::MbedTLS.SSLContext)
   @ MbedTLS ~/.julia/packages/MbedTLS/4i6Lh/src/ssl.jl:175
 [4] monitor_idle_connection(c::HTTP.ConnectionPool.Connection)
   @ HTTP.ConnectionPool ~/.julia/packages/HTTP/PesRN/src/ConnectionPool.jl:264
 [5] (::HTTP.ConnectionPool.var"#2#3"{HTTP.ConnectionPool.Connection})()
   @ HTTP.ConnectionPool ./task.jl:484
quinnj commented 2 years ago

@ararslan, ok, should be cleaned up in https://github.com/JuliaLang/MbedTLS.jl/pull/257