Skip to content

Fix test_tls13_ticket_set_alloc_fail with --enable-trackmemory - #12063

Draft
ohki-saito wants to merge 1 commit into
wolfSSL:masterfrom
ohki-saito:fix/allocater
Draft

ohki-saito wants to merge 1 commit into
wolfSSL:masterfrom
ohki-saito:fix/allocater

Conversation

@ohki-saito

Copy link
Copy Markdown
Contributor

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

  • added tests
  • updated/added doxygen
  • updated appropriate READMEs
  • Updated manual and documentation

Copilot AI balanced review requested due to automatic review settings November 9, 2026 07:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note

Copilot was unable to run its full agentic suite in this review.

Copilot review overview

4 open issues
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 thread tests/api/test_tls13.c
Comment on lines +13155 to +13156
return (ticket_alloc_prev_malloc != NULL) ?
ticket_alloc_prev_malloc(size) : malloc(size);
Comment thread tests/api/test_tls13.c
Comment on lines +13161 to +13164
if (ticket_alloc_prev_free != NULL)
ticket_alloc_prev_free(ptr);
else
free(ptr);
Comment thread tests/api/test_tls13.c
Comment on lines +13169 to +13170
return (ticket_alloc_prev_realloc != NULL) ?
ticket_alloc_prev_realloc(ptr, size) : realloc(ptr, size);
Comment thread tests/api/test_tls13.c
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));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants