Project

General

Profile

Actions

Bug #14268

closed

Heap-use-after-free in `http_server_clean_close` test

Added by Aleksei Davydov 2 months ago. Updated 14 days ago.

Status:
Closed
Priority:
High
Target version:
Start date:
01/20/2026
Due date:
% Done:

0%

Estimated time:

Description

Problem

A heap-use-after-free crash was identified in the test.http executable, specifically in the http_server_clean_close test case when running it multiple times (floating bug) on Ubuntu 24.04 with AddressSanitizer (ASan) enabled.

Probably, the root Cause

The crash occurs during server shutdown in http::server::Server::handleStop().

  1. handleStop() calls tcp_listeners_.clear(), which destroys the TcpListener objects.
  2. Each TcpListener owns a new_connection (TcpConnectionPtr), which in turn owns an asio::ip::tcp::socket.
  3. However, an asynchronous async_accept() operation might still be pending on that socket.
  4. When asio attempts to cancel the pending operation (due to the acceptor closing), it accesses the socket object that has already been freed.

ASan Trace Highlights

  • Freed by: http::server::TcpConnection::~TcpConnection() called via tcp_listeners_.clear() in Server::handleStop().
  • Read (UAF): boost::asio::detail::io_object_impl<...>::get_service() within the asio accept completion chain.

How to Reproduce

  1. Was reproduced on current master and on 4.10.3
  2. Use an environment with Ubuntu 24.04.
  3. Build wt with tests and ASan enabled: cmake -DBUILD_TESTS=ON -DCMAKE_CXX_FLAGS="-fsanitize=address" ... make
  4. Run the specific test case under stress: for i in {1..100}; do ./test.http --run_test=http_server_clean_close || break; done The crash usually occurs within 20 iterations.
Actions #1

Updated by Romain Mardulyn about 2 months ago

  • Private changed from No to Yes
Actions #2

Updated by Romain Mardulyn about 2 months ago

  • Status changed from New to InProgress
  • Priority changed from Normal to High
  • Target version set to 4.12.3
Actions #3

Updated by Romain Mardulyn about 2 months ago

  • Status changed from InProgress to Review
Actions #4

Updated by Romain Mardulyn about 1 month ago

  • Status changed from Review to Implemented @Emweb
  • Assignee set to Romain Mardulyn
Actions #5

Updated by Romain Mardulyn about 1 month ago

  • Status changed from Implemented @Emweb to InProgress
Actions #6

Updated by Romain Mardulyn about 1 month ago

  • Target version changed from 4.12.3 to 4.12.4
Actions #7

Updated by Romain Mardulyn about 1 month ago

  • Status changed from InProgress to Review
  • Assignee deleted (Romain Mardulyn)
Actions #8

Updated by Romain Mardulyn 29 days ago

  • Target version changed from 4.12.4 to 4.12.6
Actions #9

Updated by Romain Mardulyn 22 days ago

  • Assignee set to Raf Pauwels
Actions #10

Updated by Raf Pauwels 19 days ago

  • Status changed from Review to Resolved
  • Assignee changed from Raf Pauwels to Romain Mardulyn
Actions #11

Updated by Romain Mardulyn 18 days ago

  • Status changed from Resolved to Implemented @Emweb
Actions #12

Updated by Romain Mardulyn 14 days ago

  • Status changed from Implemented @Emweb to Closed
  • Private changed from Yes to No
Actions

Also available in: Atom PDF