<p dir="auto">Backtrace from <a href="https://travis-ci.org/JuliaWeb/HTTP.jl/jobs/425829426" rel="nofollow">HTTP.jl travis run</a>:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="running async 1, 1:100, Pair{Symbol,Int64}[:verbose=&gt;0], http C
[ Info: Accept (1):  🔗    0↑     0↓    0s 127.0.0.1:8081:8081 ≣16
(HTTP.Sockets).getsockname(http) = (ip&quot;127.0.0.1&quot;, 0x1f91)[ Info: Closed (1):  💀    0↑     0↓🔒   0s 127.0.0.1:8081:8081 ≣16
signal (11): Segmentation fault: 11
in expression starting at /Users/travis/build/JuliaWeb/HTTP.jl/test/async.jl:189
uv_tcp_getsockname at /Users/osx/buildbot/slave/package_osx64/build/deps/srccache/libuv-ed3700c849289ed01fe04273a7bf865340b2bd7e/src/unix/tcp.c:222
jl_tcp_getsockname at /Users/osx/buildbot/slave/package_osx64/build/src/jl_uv.c:647
_sockname at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/Sockets/src/Sockets.jl:601 [inlined]
getsockname at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/Sockets/src/Sockets.jl:584 [inlined]
getsockname at /Users/travis/build/JuliaWeb/HTTP.jl/src/Streams.jl:59 [inlined]
macro expansion at ./show.jl:555 [inlined]
#109 at /Users/travis/build/JuliaWeb/HTTP.jl/test/async.jl:17
handle_stream at /Users/travis/build/JuliaWeb/HTTP.jl/src/Servers.jl:481
#54 at ./task.jl:259
jl_apply at /Users/osx/buildbot/slave/package_osx64/build/src/./julia.h:1558 [inlined]
start_task at /Users/osx/buildbot/slave/package_osx64/build/src/task.c:271
Allocations: 88437210 (Pool: 88416323; Big: 20887); GC: 198
ERROR: Package HTTP errored during testing
Stacktrace:
 [1] pkgerror(::String, ::Vararg{String,N} where N) at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/Pkg/src/Types.jl:120
 [2] macro expansion at ./logging.jl:313 [inlined]
 [3] #test#61(::Bool, ::Function, ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/Pkg/src/Operations.jl:1284
 [4] #test at ./none:0 [inlined]
 [5] #test#42(::Bool, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:267
 [6] #test at ./none:0 [inlined]
 [7] #test#41 at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:250 [inlined]
 [8] #test at ./none:0 [inlined]
 [9] #test#38(::Base.Iterators.Pairs{Symbol,Bool,Tuple{Symbol},NamedTuple{(:coverage,),Tuple{Bool}}}, ::Function) at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:247
 [10] (::getfield(Pkg.API, Symbol(&quot;#kw##test&quot;)))(::NamedTuple{(:coverage,),Tuple{Bool}}, ::typeof(Pkg.API.test)) at ./none:0
 [11] top-level scope at none:1"><pre class="notranslate">running async <span class="pl-c1">1</span>, <span class="pl-c1">1</span><span class="pl-k">:</span><span class="pl-c1">100</span>, Pair{Symbol,Int64}[<span class="pl-c1">:verbose</span><span class="pl-k">=&gt;</span><span class="pl-c1">0</span>], http C
[ Info<span class="pl-k">:</span> Accept (<span class="pl-c1">1</span>)<span class="pl-k">:</span>  🔗    <span class="pl-c1">0</span>↑     <span class="pl-c1">0</span>↓    <span class="pl-c1">0</span>s <span class="pl-c1">127.0</span>.<span class="pl-c1">0.1</span><span class="pl-k">:</span><span class="pl-c1">8081</span><span class="pl-k">:</span><span class="pl-c1">8081</span> ≣<span class="pl-c1">16</span>
(HTTP<span class="pl-k">.</span>Sockets)<span class="pl-k">.</span><span class="pl-en">getsockname</span>(http) <span class="pl-k">=</span> (<span class="pl-s"><span class="pl-pds"><span class="pl-c1">ip</span>"</span>127.0.0.1<span class="pl-pds">"</span></span>, <span class="pl-c1">0x1f91</span>)[ Info<span class="pl-k">:</span> Closed (<span class="pl-c1">1</span>)<span class="pl-k">:</span>  💀    <span class="pl-c1">0</span>↑     <span class="pl-c1">0</span>↓🔒   <span class="pl-c1">0</span>s <span class="pl-c1">127.0</span>.<span class="pl-c1">0.1</span><span class="pl-k">:</span><span class="pl-c1">8081</span><span class="pl-k">:</span><span class="pl-c1">8081</span> ≣<span class="pl-c1">16</span>
signal (<span class="pl-c1">11</span>)<span class="pl-k">:</span> Segmentation fault<span class="pl-k">:</span> <span class="pl-c1">11</span>
in expression starting at <span class="pl-k">/</span>Users<span class="pl-k">/</span>travis<span class="pl-k">/</span>build<span class="pl-k">/</span>JuliaWeb<span class="pl-k">/</span>HTTP<span class="pl-k">.</span>jl<span class="pl-k">/</span>test<span class="pl-k">/</span>async<span class="pl-k">.</span>jl<span class="pl-k">:</span><span class="pl-c1">189</span>
uv_tcp_getsockname at <span class="pl-k">/</span>Users<span class="pl-k">/</span>osx<span class="pl-k">/</span>buildbot<span class="pl-k">/</span>slave<span class="pl-k">/</span>package_osx64<span class="pl-k">/</span>build<span class="pl-k">/</span>deps<span class="pl-k">/</span>srccache<span class="pl-k">/</span>libuv<span class="pl-k">-</span>ed3700c849289ed01fe04273a7bf865340b2bd7e<span class="pl-k">/</span>src<span class="pl-k">/</span>unix<span class="pl-k">/</span>tcp<span class="pl-k">.</span>c<span class="pl-k">:</span><span class="pl-c1">222</span>
jl_tcp_getsockname at <span class="pl-k">/</span>Users<span class="pl-k">/</span>osx<span class="pl-k">/</span>buildbot<span class="pl-k">/</span>slave<span class="pl-k">/</span>package_osx64<span class="pl-k">/</span>build<span class="pl-k">/</span>src<span class="pl-k">/</span>jl_uv<span class="pl-k">.</span>c<span class="pl-k">:</span><span class="pl-c1">647</span>
_sockname at <span class="pl-k">/</span>Users<span class="pl-k">/</span>osx<span class="pl-k">/</span>buildbot<span class="pl-k">/</span>slave<span class="pl-k">/</span>package_osx64<span class="pl-k">/</span>build<span class="pl-k">/</span>usr<span class="pl-k">/</span>share<span class="pl-k">/</span>julia<span class="pl-k">/</span>stdlib<span class="pl-k">/</span>v1.<span class="pl-c1">1</span><span class="pl-k">/</span>Sockets<span class="pl-k">/</span>src<span class="pl-k">/</span>Sockets<span class="pl-k">.</span>jl<span class="pl-k">:</span><span class="pl-c1">601</span> [inlined]
getsockname at <span class="pl-k">/</span>Users<span class="pl-k">/</span>osx<span class="pl-k">/</span>buildbot<span class="pl-k">/</span>slave<span class="pl-k">/</span>package_osx64<span class="pl-k">/</span>build<span class="pl-k">/</span>usr<span class="pl-k">/</span>share<span class="pl-k">/</span>julia<span class="pl-k">/</span>stdlib<span class="pl-k">/</span>v1.<span class="pl-c1">1</span><span class="pl-k">/</span>Sockets<span class="pl-k">/</span>src<span class="pl-k">/</span>Sockets<span class="pl-k">.</span>jl<span class="pl-k">:</span><span class="pl-c1">584</span> [inlined]
getsockname at <span class="pl-k">/</span>Users<span class="pl-k">/</span>travis<span class="pl-k">/</span>build<span class="pl-k">/</span>JuliaWeb<span class="pl-k">/</span>HTTP<span class="pl-k">.</span>jl<span class="pl-k">/</span>src<span class="pl-k">/</span>Streams<span class="pl-k">.</span>jl<span class="pl-k">:</span><span class="pl-c1">59</span> [inlined]
<span class="pl-k">macro</span> expansion at <span class="pl-k">./</span>show<span class="pl-k">.</span>jl<span class="pl-k">:</span><span class="pl-c1">555</span> [inlined]
<span class="pl-c"><span class="pl-c">#</span>109 at /Users/travis/build/JuliaWeb/HTTP.jl/test/async.jl:17</span>
handle_stream at <span class="pl-k">/</span>Users<span class="pl-k">/</span>travis<span class="pl-k">/</span>build<span class="pl-k">/</span>JuliaWeb<span class="pl-k">/</span>HTTP<span class="pl-k">.</span>jl<span class="pl-k">/</span>src<span class="pl-k">/</span>Servers<span class="pl-k">.</span>jl<span class="pl-k">:</span><span class="pl-c1">481</span>
<span class="pl-c"><span class="pl-c">#</span>54 at ./task.jl:259</span>
jl_apply at <span class="pl-k">/</span>Users<span class="pl-k">/</span>osx<span class="pl-k">/</span>buildbot<span class="pl-k">/</span>slave<span class="pl-k">/</span>package_osx64<span class="pl-k">/</span>build<span class="pl-k">/</span>src<span class="pl-k">/./</span>julia<span class="pl-k">.</span>h<span class="pl-k">:</span><span class="pl-c1">1558</span> [inlined]
start_task at <span class="pl-k">/</span>Users<span class="pl-k">/</span>osx<span class="pl-k">/</span>buildbot<span class="pl-k">/</span>slave<span class="pl-k">/</span>package_osx64<span class="pl-k">/</span>build<span class="pl-k">/</span>src<span class="pl-k">/</span>task<span class="pl-k">.</span>c<span class="pl-k">:</span><span class="pl-c1">271</span>
Allocations<span class="pl-k">:</span> <span class="pl-c1">88437210</span> (Pool<span class="pl-k">:</span> <span class="pl-c1">88416323</span>; Big<span class="pl-k">:</span> <span class="pl-c1">20887</span>); GC<span class="pl-k">:</span> <span class="pl-c1">198</span>
ERROR<span class="pl-k">:</span> Package HTTP errored during testing
Stacktrace<span class="pl-k">:</span>
 [<span class="pl-c1">1</span>] <span class="pl-c1">pkgerror</span>(<span class="pl-k">::</span><span class="pl-c1">String</span>, <span class="pl-k">::</span><span class="pl-c1">Vararg{String,N}</span> <span class="pl-k">where</span> N) at <span class="pl-k">/</span>Users<span class="pl-k">/</span>osx<span class="pl-k">/</span>buildbot<span class="pl-k">/</span>slave<span class="pl-k">/</span>package_osx64<span class="pl-k">/</span>build<span class="pl-k">/</span>usr<span class="pl-k">/</span>share<span class="pl-k">/</span>julia<span class="pl-k">/</span>stdlib<span class="pl-k">/</span>v1.<span class="pl-c1">1</span><span class="pl-k">/</span>Pkg<span class="pl-k">/</span>src<span class="pl-k">/</span>Types<span class="pl-k">.</span>jl<span class="pl-k">:</span><span class="pl-c1">120</span>
 [<span class="pl-c1">2</span>] <span class="pl-k">macro</span> expansion at <span class="pl-k">./</span>logging<span class="pl-k">.</span>jl<span class="pl-k">:</span><span class="pl-c1">313</span> [inlined]
 [<span class="pl-c1">3</span>] <span class="pl-c"><span class="pl-c">#</span>test#61(::Bool, ::Function, ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/Pkg/src/Operations.jl:1284</span>
 [<span class="pl-c1">4</span>] <span class="pl-c"><span class="pl-c">#</span>test at ./none:0 [inlined]</span>
 [<span class="pl-c1">5</span>] <span class="pl-c"><span class="pl-c">#</span>test#42(::Bool, ::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::Function, ::Pkg.Types.Context, ::Array{Pkg.Types.PackageSpec,1}) at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:267</span>
 [<span class="pl-c1">6</span>] <span class="pl-c"><span class="pl-c">#</span>test at ./none:0 [inlined]</span>
 [<span class="pl-c1">7</span>] <span class="pl-c"><span class="pl-c">#</span>test#41 at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:250 [inlined]</span>
 [<span class="pl-c1">8</span>] <span class="pl-c"><span class="pl-c">#</span>test at ./none:0 [inlined]</span>
 [<span class="pl-c1">9</span>] <span class="pl-c"><span class="pl-c">#</span>test#38(::Base.Iterators.Pairs{Symbol,Bool,Tuple{Symbol},NamedTuple{(:coverage,),Tuple{Bool}}}, ::Function) at /Users/osx/buildbot/slave/package_osx64/build/usr/share/julia/stdlib/v1.1/Pkg/src/API.jl:247</span>
 [<span class="pl-c1">10</span>] (<span class="pl-k">::</span><span class="pl-c1">getfield</span>(Pkg<span class="pl-k">.</span>API, <span class="pl-c1">Symbol</span>(<span class="pl-s"><span class="pl-pds">"</span>#kw##test<span class="pl-pds">"</span></span>)))(<span class="pl-k">::</span><span class="pl-c1">NamedTuple{(:coverage,),Tuple{Bool}}</span>, <span class="pl-k">::</span><span class="pl-c1">typeof</span>(Pkg<span class="pl-k">.</span>API<span class="pl-k">.</span>test)) at <span class="pl-k">./</span>none<span class="pl-k">:</span><span class="pl-c1">0</span>
 [<span class="pl-c1">11</span>] top<span class="pl-k">-</span>level scope at none<span class="pl-k">:</span><span class="pl-c1">1</span></pre></div>
<p dir="auto">I'm wondering if we need some kind of assertion around </p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/JuliaLang/julia/blob/5c1d4a33b2b2850282297c69e15601bbad669073/stdlib/Sockets/src/Sockets.jl#L601">julia/stdlib/Sockets/src/Sockets.jl</a>
    </p>
    <p class="mb-0 color-fg-muted">
         Line 601
      in
      <a data-pjax="true" class="commit-tease-sha" href="/JuliaLang/julia/commit/5c1d4a33b2b2850282297c69e15601bbad669073">5c1d4a3</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L601" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="601"></td>
          <td id="LC601" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> r <span class="pl-k">=</span> <span class="pl-c1">ccall</span>(<span class="pl-c1">:jl_tcp_getsockname</span>, Int32, </td>
        </tr>
    </tbody></table>
  </div>
</div>
. The docs say it's only valid for connected sockets, so I imagine the HTTP.jl tests got into a situation where that happened to be the case (saw this error on 1/4 builds for a single PR).<p></p>
<p dir="auto">Could probably be an error instead?</p>
<p dir="auto"><code class="notranslate">sock.handle</code> is a null pointer here<br>
</p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/JuliaLang/julia/blob/5dbf45a2997acd26e0f72abaa320c9d0d54956a1/stdlib/Sockets/src/Sockets.jl#L817">julia/stdlib/Sockets/src/Sockets.jl</a>
    </p>
    <p class="mb-0 color-fg-muted">
         Line 817
      in
      <a data-pjax="true" class="commit-tease-sha" href="/JuliaLang/julia/commit/5dbf45a2997acd26e0f72abaa320c9d0d54956a1">5dbf45a</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L817" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="817"></td>
          <td id="LC817" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> sock<span class="pl-k">.</span>handle, rport, raddress, rfamily) </td>
        </tr>
    </tbody></table>
  </div>
</div>
 and here <div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/JuliaLang/julia/blob/5dbf45a2997acd26e0f72abaa320c9d0d54956a1/stdlib/Sockets/src/Sockets.jl#L821">julia/stdlib/Sockets/src/Sockets.jl</a>
    </p>
    <p class="mb-0 color-fg-muted">
         Line 821
      in
      <a data-pjax="true" class="commit-tease-sha" href="/JuliaLang/julia/commit/5dbf45a2997acd26e0f72abaa320c9d0d54956a1">5dbf45a</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L821" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="821"></td>
          <td id="LC821" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> sock<span class="pl-k">.</span>handle, rport, raddress, rfamily) </td>
        </tr>
    </tbody></table>
  </div>
</div>
<p></p>
<p dir="auto">Would <code class="notranslate">peer = isopen(sock) ? getpeername(sock) : nothing</code> be a safe alternative to avoid this segfault (or error if this issue is fixed)?</p>