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

'assertion failed: self.upgrade.is_none()' when reusing connection with ignored upgrade header #2114

Closed
ggriffiniii opened this issue Jan 23, 2020 · 4 comments · Fixed by #2115
Labels
A-http1 Area: HTTP/1 specific. C-bug Category: bug. Something is wrong. This is bad!

Comments

@ggriffiniii
Copy link

Hyper threads panic (though the server remains running) when a client makes multiple requests with an upgrade header (which hyper ignores). The first request is handled without issue, but when the second request is made the hyper thread panics and the connection is terminated.

Steps to reproduce:

  • Run the hello world example
    • cargo run --example hello
  • issue multiple requests over the same connection with an Upgrade header.
  • curl -v -H "Connection: Upgrade" -H "Upgrade: foo" http://127.0.0.1:3000 http://127.0.0.1:3000

The hyper output:

Listening on http://127.0.0.1:3000
thread 'main' panicked at 'assertion failed: self.upgrade.is_none()', src/proto/h1/conn.rs:905:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

The curl output:

*   Trying 127.0.0.1:3000...
* TCP_NODELAY set
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0* Connected to 127.0.0.1 (127.0.0.1) port 3000 (#0)
> GET / HTTP/1.1
> Host: 127.0.0.1:3000
> User-Agent: curl/7.66.0
> Accept: */*
> Connection: Upgrade
> Upgrade: foo
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< content-length: 12
< date: Thu, 23 Jan 2020 23:45:26 GMT
< 
{ [12 bytes data]

100    12  100    12    0     0  12000      0 --:--:-- --:--:-- --:--:-- 12000
* Connection #0 to host 127.0.0.1 left intact
Hello World!* Found bundle for host 127.0.0.1: 0x5649a99f0170 [serially]
* Can not multiplex, even if we wanted to!
* Re-using existing connection! (#0) with host 127.0.0.1
* Connected to 127.0.0.1 (127.0.0.1) port 3000 (#0)
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0> GET / HTTP/1.1
> Host: 127.0.0.1:3000
> User-Agent: curl/7.66.0
> Accept: */*
> Connection: Upgrade
> Upgrade: foo
> 
* Connection died, retrying a fresh connect

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
* Closing connection 0
* Issue another request to this URL: 'http://127.0.0.1:3000/'
* Hostname 127.0.0.1 was found in DNS cache
*   Trying 127.0.0.1:3000...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 3000 (#1)
> GET / HTTP/1.1
> Host: 127.0.0.1:3000
> User-Agent: curl/7.66.0
> Accept: */*
> Connection: Upgrade
> Upgrade: foo
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< content-length: 12
< date: Thu, 23 Jan 2020 23:45:26 GMT
< 
{ [12 bytes data]

100    12  100    12    0     0  12000      0 --:--:-- --:--:-- --:--:-- 12000
* Connection #1 to host 127.0.0.1 left intact
Hello World!

You can see that the connection dies when the second request is issued (corresponding to the panic in the hyper output), curl then establishes a new connection and reissues the request which succeeds.

@seanmonstar seanmonstar added A-http1 Area: HTTP/1 specific. C-bug Category: bug. Something is wrong. This is bad! labels Jan 23, 2020
@seanmonstar
Copy link
Member

Looks like a debug_assert, but I can't possibly remember why it's there...

@ggriffiniii
Copy link
Author

Thanks for the really quick response

@seanmonstar
Copy link
Member

Note that until the new version, compiling without debug assertions (normal in release mode) should fix it too.

@ggriffiniii
Copy link
Author

yeah, thanks. I should have mentioned when opening the issue that it was only a debug_assert. In my case I'm using hyper in my httptest. The purpose of that crate is to provide a server to test against so it's typically built in debug mode. Thanks for the suggestion though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-http1 Area: HTTP/1 specific. C-bug Category: bug. Something is wrong. This is bad!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants