Repository navigation
Fix test_tls13_ticket_set_alloc_fail with --enable-trackmemory - #12063
Draft
ohki-saito wants to merge 1 commit into
Draft
ohki-saito wants to merge 1 commit into
ohki-saito wants to merge 1 commit into
Conversation
Copilot stopped reviewing on behalf of
ohki-saito due to an error
November 9, 2026 07:32
Contributor
There was a problem hiding this comment.
Note
Copilot was unable to run its full agentic suite in this review.
Copilot review overview
4 open issues
The fallback logic can mix allocators (e.g., allocate viaticket_alloc_prev_mallocbut free via… · New The fallback logic can mix allocators (e.g., allocate viaticket_alloc_prev_mallocbut free via… · New The fallback logic can mix allocators (e.g., allocate viaticket_alloc_prev_mallocbut free via… · New If anyExpectIntEQ(...)inside the block fails, execution typically continues, which can leave… · New
What changed in this PR
Adjusts the TLS 1.3 session ticket allocation-failure test to wrap the “real” allocators (the ones installed before the test) so allocations can be cleaned up correctly after allocator restoration.
Changes:
- Store the pre-test allocator callbacks in file-scope statics and route allocations/frees through them.
- Update the failure-injection malloc/free/realloc wrappers to call the previous callbacks when present.
- Replace per-test local “prev allocator” variables with the new statics.
| File | Description |
|---|---|
| tests/api/test_tls13.c | Routes test allocation wrappers through previously installed allocators and updates the test to restore allocator state using saved callbacks. |
Review effort: Lite
Comment on lines
+13155
to
+13156
| return (ticket_alloc_prev_malloc != NULL) ? | ||
| ticket_alloc_prev_malloc(size) : malloc(size); |
Comment on lines
+13161
to
+13164
| if (ticket_alloc_prev_free != NULL) | ||
| ticket_alloc_prev_free(ptr); | ||
| else | ||
| free(ptr); |
Comment on lines
+13169
to
+13170
| return (ticket_alloc_prev_realloc != NULL) ? | ||
| ticket_alloc_prev_realloc(ptr, size) : realloc(ptr, size); |
Comment on lines
13220
to
13233
| ExpectIntEQ(wolfSSL_send_SessionTicket(ssl_s), WOLFSSL_SUCCESS); | ||
| if (EXPECT_SUCCESS()) { | ||
| ticket_alloc_fail_sz = ssl_c->session->ticketLen; | ||
| ExpectIntEQ(wolfSSL_GetAllocators(&prevM, &prevF, &prevR), 0); | ||
| ExpectIntEQ(wolfSSL_GetAllocators(&ticket_alloc_prev_malloc, | ||
| &ticket_alloc_prev_free, &ticket_alloc_prev_realloc), 0); | ||
| ExpectIntEQ(wolfSSL_SetAllocators(ticket_alloc_fail_malloc, | ||
| ticket_alloc_fail_free, ticket_alloc_fail_realloc), 0); | ||
| ExpectIntEQ(wolfSSL_read(ssl_c, readBuf, sizeof(readBuf)), -1); | ||
| ticket_alloc_fail_sz = 0; | ||
| (void)wolfSSL_SetAllocators(prevM, prevF, prevR); | ||
| (void)wolfSSL_SetAllocators(ticket_alloc_prev_malloc, | ||
| ticket_alloc_prev_free, ticket_alloc_prev_realloc); | ||
| ExpectIntEQ(wolfSSL_get_error(ssl_c, -1), | ||
| WC_NO_ERR_TRACE(MEMORY_E)); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Non-Fenrir findings
test_tls13_ticket_set_alloc_fail aborts with --enable-trackmemory because its allocators call raw malloc/free, while the ticket buffer was allocated by TrackMalloc before the swap. Delegate to the saved allocators instead, as done for the PKCS12 and OCSP OOM tests.
Other tests also call raw malloc/free in their allocators, but they don’t fail with --enable-trackmemory today.
Testing
make check with --enable-all --enable-trackmemory.
Checklist