Copilot commented on code in PR #13029:
URL: https://github.com/apache/trafficserver/pull/13029#discussion_r2999025524


##########
src/proxy/hdrs/unit_tests/test_Hdrs.cc:
##########
@@ -438,6 +442,9 @@ test_http_hdr_print_and_copy_aux(int testnum, const char 
*request, const char *r
 
   if ((prt_ret != 1) || (cpy_ret != 1)) {
     std::printf("FAILED: (test #%d) couldn't print req hdr or copy --- 
prt_ret=%d, cpy_ret=%d\n", testnum, prt_ret, cpy_ret);
+    hdr.destroy();
+    new_hdr.destroy();
+

Review Comment:
   The error branches here now manually destroy `hdr`/`new_hdr` in several 
places. To make this less error-prone (and avoid reintroducing leaks on future 
edits), consider using an RAII guard (e.g., `ts::PostScript` like other tests 
in this file) for `hdr` and `new_hdr`, so cleanup happens automatically on all 
returns while still leaving `marshal_hdr` intentionally undisposed.



##########
ci/asan_leak_suppression/unit_tests.txt:
##########
@@ -1,10 +1,4 @@
-# leaks in test_X509HostnameValidator
-leak:libcrypto.so.1.1
-# for OpenSSL 1.0.2:
-leak:CRYPTO_malloc
-leak:CRYPTO_realloc
-leak:ConsCell
-# PR#10295
-leak:pcre_jit_stack_alloc
-# PR#10541
+# marshal_hdr in test_http_hdr_print_and_copy_aux is intentionally
+# not destroyed because it holds a reference to a stack-allocated
+# TestRefCountObj whose free() override calls exit(1).
 leak:test_http_hdr_print_and_copy_aux

Review Comment:
   This suppression is now the only remaining unit-test leak entry. It looks 
like the leak may be avoidable in `test_http_hdr_print_and_copy_aux`: 
`marshal_hdr.create()` allocates a new heap, and `unmarshal()` then overwrites 
`m_heap` with the marshalled buffer, which can strand the initially allocated 
heap. If `marshal_hdr` is left un-created before `unmarshal()` (or otherwise 
prevented from allocating a heap first), the test may no longer need a leak 
suppression here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to