mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:35:53 +01:00
[PR #1821] runtime: fix PipelineWorkers stack use-after-free on OOM in start() (RT-PIPELINE-WORKERS-OOM-UAF) #1833
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1833
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1821
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/rt-pipeline-workers-oom-uaf📝 Commits (1)
703dfb4runtime: fix PipelineWorkers stack use-after-free on OOM in start() (RT-PIPELINE-WORKERS-OOM-UAF)📊 Changes
2 files changed (+112 additions, -2 deletions)
View changed files
📝
runtime/src/pipeline_workers.h(+11 -2)📝
runtime/test/pipeline_workers_test.cpp(+101 -0)📄 Description
Summary
Item:
RT-PIPELINE-WORKERS-OOM-UAFClaim: https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7162472188
Fixes a stack use-after-free and OOM submission failure in
leonida::PipelineWorkers::run()(runtime/src/pipeline_workers.h):&batchtoqueue_: previouslyrun()pushed the address of its stack-localBatchontoqueue_and updatedbatches_/jobs_before callingstart(count - 1). Becausestart()only caughtstd::system_errorand notstd::bad_alloc, an allocation failure growingthreads_(or allocating astd::threadcontrol block) unwoundrun()and destroyedbatchon the stack while leaving&batchdangling inqueue_. The next wakeup of any existing worker dereferenced the freed stack frame (AddressSanitizer: stack-use-after-returnatpipeline_workers.h:120).std::bad_allocinstart()andqueue_.push_back():start()catchesstd::bad_allocand breaks out of the growth loop without permanently latchingexhausted_, so the existing workers and caller complete the current batch and later batches can scale up again once memory is available.run()guardsqueue_.push_back(&batch)againststd::bad_alloc; if enqueuing fails, it unlocksmutex_and runs the batch inline on the calling thread without mutatingbatches_/jobs_or publishing a dangling pointer.oom_during_start_and_enqueue()toruntime/test/pipeline_workers_test.cppusing a thread-localoperator newfailure injector covering both mid-growth OOM (which deterministically triggers ASanstack-use-after-returnonmain) and hard first-batch OOM with inline fallback and post-OOM recovery.Testing
clang++(C++20)runtime/test/pipeline_workers_test.cppwith-std=c++20 -Wall -Wextra -Werror:ASAN_OPTIONS=detect_stack_use_after_return=1):pipeline_workers_test: passed-fsanitize=thread):pipeline_workers_test: passed(0 data races)-O2× 3 runs:pipeline_workers_test: passedmain(0d80bc5df): compiled the updatedpipeline_workers_test.cppagainstmain:runtime/src/pipeline_workers.hunder ASan (detect_stack_use_after_return=1); reproducedERROR: AddressSanitizer: stack-use-after-returninPipelineWorkers::step(pipeline_workers.h:120, rc=134).python3 -I scripts/check_no_game_data.py runtime/src/pipeline_workers.h runtime/test/pipeline_workers_test.cppandpython3 -I tests/test_text_write_line_endings.py: both passed.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.