Skip to content

http2: Node crashes with an assertion error if an http2 server is closed after receiving and rejecting very large headers #35233

Closed
@murgatroid99

Description

@murgatroid99
  • Version: 14.10.0
  • Platform: Linux DESKTOP-OKC3QBQ 4.4.0-18362-Microsoft Crypto tests overhaul #1049-Microsoft Thu Aug 14 12:01:00 PST 2020 x86_64 x86_64 x86_64 GNU/Linux
  • Subsystem: http2

What steps will reproduce the bug?

const http2 = require('http2');

const server = http2.createServer({
  maxSendHeaderBlockLength: Number.MAX_SAFE_INTEGER
});

server.on('stream', (stream, headers) => {
  stream.respond();
  stream.end();
});

server.listen(8080, () => {
  const clientSession = http2.connect('http://localhost:8080', {
    maxSendHeaderBlockLength: Number.MAX_SAFE_INTEGER
  });

  clientSession.on('error', (error) => {
    console.log(error);
  })

  const stream = clientSession.request({
    'test-header': 'A'.repeat(90000)
  });

  stream.on('close', () => {
    console.log(`Stream closed with RST_STREAM code ${stream.rstCode}`);
    server.close();
  });

  stream.on('error', (error) => {
    console.log(error);
  })

  stream.end();
});

How often does it reproduce? Is there a required condition?

This reproduction is 100% consistent.

What is the expected behavior?

Error [ERR_HTTP2_SESSION_ERROR]: Session closed with error code 9
    at Http2Session.onGoawayData (internal/http2/core.js:642:21) {
  code: 'ERR_HTTP2_SESSION_ERROR'
}
Stream closed with RST_STREAM code 9
Error [ERR_HTTP2_SESSION_ERROR]: Session closed with error code 9
    at Http2Session.onGoawayData (internal/http2/core.js:642:21) {
  code: 'ERR_HTTP2_SESSION_ERROR'
}

What do you see instead?

Error [ERR_HTTP2_SESSION_ERROR]: Session closed with error code 9
    at Http2Session.onGoawayData (internal/http2/core.js:642:21) {
  code: 'ERR_HTTP2_SESSION_ERROR'
}
Stream closed with RST_STREAM code 9
Error [ERR_HTTP2_SESSION_ERROR]: Session closed with error code 9
    at Http2Session.onGoawayData (internal/http2/core.js:642:21) {
  code: 'ERR_HTTP2_SESSION_ERROR'
}
node[5776]: ../src/node_http2.cc:522:virtual node::http2::Http2Session::~Http2Session(): Assertion `(current_nghttp2_memory_) == (0)' failed.
 1: 0xa02dd0 node::Abort() [node]
 2: 0xa02e4e  [node]
 3: 0xa274aa node::http2::Http2Session::~Http2Session() [node]
 4: 0xa27611 node::http2::Http2Session::~Http2Session() [node]
 5: 0x9a9dbb node::Environment::RunCleanup() [node]
 6: 0x96d3d7 node::FreeEnvironment(node::Environment*) [node]
 7: 0xa42d6f node::NodeMainInstance::Run() [node]
 8: 0x9d10e5 node::Start(int, char**) [node]
 9: 0x7f9b63f60830 __libc_start_main [/lib/x86_64-linux-gnu/libc.so.6]
10: 0x9697bc  [node]
Aborted (core dumped)

Additional information

This is related to #35218 regarding the handling of very large request headers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.http2Issues or PRs related to the http2 subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions