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

ssl:recv/3 called with negative Length #722

Closed
AnufrievDE opened this issue Aug 2, 2023 · 9 comments · Fixed by #724
Closed

ssl:recv/3 called with negative Length #722

AnufrievDE opened this issue Aug 2, 2023 · 9 comments · Fixed by #724
Assignees

Comments

@AnufrievDE
Copy link

Hello,

I've faced this error, after updating hackney from 3f6d481 to master d6d075f.

According the traces collected within dbg:tpl(ssl, recv, 3, cx), it seems that ssl:recv is called from hackney_response:stream_body_recv/2 with wrong second argument: Length = -1:

(<0.31924.4357>) call ssl:recv({sslsocket,{gen_tcp,#Port<0.5997548>,tls_connection,undefined
},
           [<0.28413.4369>,<0.16905.4328>]},-1,5000) ({hackney_response,
                                                       stream_body_recv,2})
...
(<0.31924.4357>) exception_from {ssl,recv,3} {exit,{{{case_clause,[]},
        [{ssl_gen_statem,iovec_from_front,4,
                         [{file,"ssl_gen_statem.erl"},{line,1650}]},
         {ssl_gen_statem,read_application_data_bin,8,
                         [{file,"ssl_gen_statem.erl"},{line,1486}]},
         {ssl_gen_statem,passive_receive,4,
                         [{file,"ssl_gen_statem.erl"},{line,939}]},
         {gen_statem,loop_state_callback,11,
                     [{file,"gen_statem.erl"},{line,1426}]},
         {tls_connection,init,1,[{file,"tls_connection.erl"},{line,160}]},
         {proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,240}]}]},
       {gen_statem,call,[<0.28413.4369>,{recv,-1,5000},infinity]}}}

It probably related to this pull request.

@nulian
Copy link

nulian commented Aug 31, 2023

@benoitc This bug is now released and breaks multiple requests for us with latest hackney.

@tarzan
Copy link

tarzan commented Aug 31, 2023

UP! This forced us to revert the update from hackney 1.8.2 back to 1.8.1 as well. Got this stacktrace in my Elixir app:

** (exit) exited in: :gen_statem.call(#PID<0.187518.0>, {:recv, -1, 5000}, :infinity)
    ** (EXIT) an exception was raised:
        ** (CaseClauseError) no case clause matching: []
            (ssl 11.0.1) ssl_gen_statem.erl:1715: :ssl_gen_statem.iovec_from_front/4
            (ssl 11.0.1) ssl_gen_statem.erl:1551: :ssl_gen_statem.read_application_data_bin/8
            (ssl 11.0.1) tls_gen_connection.erl:427: :tls_gen_connection.handle_protocol_record/3
            (stdlib 5.0.1) gen_statem.erl:1377: :gen_statem.loop_state_callback/11
            (ssl 11.0.1) tls_connection.erl:162: :tls_connection.init/1
            (stdlib 5.0.1) proc_lib.erl:241: :proc_lib.init_p_do_apply/3
    (stdlib 5.0.1) gen.erl:246: :gen.do_call/4
    (stdlib 5.0.1) gen_statem.erl:905: :gen_statem.call/3
    (ssl 11.0.1) ssl_gen_statem.erl:1319: :ssl_gen_statem.call/2
    (hackney 1.18.2) /home/runner/work/my_app/my_app/deps/hackney/src/hackney_response.erl:170: :hackney_response.stream_body_recv/2
    (hackney 1.18.2) /home/runner/work/my_app/my_app/deps/hackney/src/hackney_response.erl:312: :hackney_response.read_body/3
    (hackney 1.18.2) /home/runner/work/my_app/my_app/deps/hackney/src/hackney.erl:520: anonymous fn/2 in :hackney.body/2
    (httpoison 2.1.0) lib/httpoison/base.ex:888: HTTPoison.Base.request/6
    iex:13: (file)

I would strongly advise pulling this release

@gmile
Copy link
Contributor

gmile commented Sep 6, 2023

We had to downgrade from 1.8.2 to 1.8.1 due to this issue exactly.

@seb3s
Copy link

seb3s commented Sep 14, 2023

Same here, a downgrade from 1.8.2 to 1.8.1 was required

@conradfr
Copy link

Same here.

What I used in mix (if that helps anyone):
{:hackney, git: "https://github.com/benoitc/hackney.git", tag: "1.18.1", override: true},

Also I can't understand why it's not catch in a try/catch when thrown inside a Httpoison.get! call ?

@benoitc
Copy link
Owner

benoitc commented Sep 15, 2023

isssue have been introduced in 5e74354 . working on it.

@benoitc
Copy link
Owner

benoitc commented Sep 15, 2023

Please check #724 PR and let me know.

@benoitc
Copy link
Owner

benoitc commented Sep 20, 2023

fixed in maint.

@AnufrievDE
Copy link
Author

Thanks! I'll check

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants