Skip to content

Commit 77beafa

Browse files
authored
Clean up stale LSAN suppression entries (#13029)
* Fix HTTPHdr leaks in test helpers using ts::PostScript scope guards instead of manual destroy() on every error path. * Remove goto/done pattern in test_http_hdr_copy_over_aux, replace with if-not-error chaining. * Remove 3 stale regression LSAN suppressions for deleted or Catch2-converted tests. * Remove 6 obsolete unit test suppressions for OpenSSL 1.0.2, OpenSSL 1.1, ConsCell, and PCRE1. * Restore TSHttpConnect suppressions -- generate_request still leaks.
1 parent 4f97333 commit 77beafa

3 files changed

Lines changed: 29 additions & 40 deletions

File tree

ci/asan_leak_suppression/regression.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ leak:RegressionTest_PARENTSELECTION
22
leak:ParentConfig::reconfigure
33
leak:RegressionTest_SDK_API_TSHttpConnectIntercept
44
leak:RegressionTest_SDK_API_TSHttpConnectServerIntercept
5-
leak:make_log_host
65
leak:ReRegressionSM::clone
76
leak:RegressionTest_ram_cache
87
leak:RegressionTest_HttpTransact_is_request_valid
@@ -11,9 +10,7 @@ leak:MakeTextLogFormat
1110
leak:RegressionTest_HttpTransact_handle_trace_and_options_requests
1211
leak:CRYPTO_malloc
1312
leak:RegressionTest_SDK_API_TSMgmtGet
14-
leak:RegressionTest_Cache_vol
1513
leak:RegressionTest_SDK_API_TSCache
16-
leak:RegressionTest_Hdrs
1714
leak:RegressionTest_SDK_API_TSPortDescriptor
1815
leak:RegressionTest_HostDBProcessor
1916
leak:RegressionTest_DNS
Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
# leaks in test_X509HostnameValidator
2-
leak:libcrypto.so.1.1
3-
# for OpenSSL 1.0.2:
4-
leak:CRYPTO_malloc
5-
leak:CRYPTO_realloc
6-
leak:ConsCell
7-
# PR#10295
8-
leak:pcre_jit_stack_alloc
9-
# PR#10541
1+
# marshal_hdr in test_http_hdr_print_and_copy_aux is intentionally
2+
# not destroyed because it holds a reference to a stack-allocated
3+
# TestRefCountObj whose free() override calls exit(1).
104
leak:test_http_hdr_print_and_copy_aux

src/proxy/hdrs/unit_tests/test_Hdrs.cc

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,13 @@ test_http_hdr_copy_over_aux(int testnum, const char *request, const char *respon
183183
HTTPHdr copy1;
184184
HTTPHdr copy2;
185185

186+
ts::PostScript cleanup([&]() -> void {
187+
req_hdr.destroy();
188+
resp_hdr.destroy();
189+
copy1.destroy();
190+
copy2.destroy();
191+
});
192+
186193
HTTPParser parser;
187194
const char *start;
188195
const char *end;
@@ -236,48 +243,36 @@ test_http_hdr_copy_over_aux(int testnum, const char *request, const char *respon
236243
copy1.create(HTTPType::REQUEST);
237244
copy1.copy(&req_hdr);
238245
comp_str = comp_http_hdr(&req_hdr, &copy1);
239-
if (comp_str) {
240-
goto done;
241-
}
242246

243-
copy2.create(HTTPType::RESPONSE);
244-
copy2.copy(&resp_hdr);
245-
comp_str = comp_http_hdr(&resp_hdr, &copy2);
246-
if (comp_str) {
247-
goto done;
247+
if (!comp_str) {
248+
copy2.create(HTTPType::RESPONSE);
249+
copy2.copy(&resp_hdr);
250+
comp_str = comp_http_hdr(&resp_hdr, &copy2);
248251
}
249252

250253
// The APIs for copying headers uses memcpy() which can be unsafe for
251254
// overlapping memory areas. It's unclear to me why these tests were
252255
// created in the first place honestly, since nothing else does this.
253256

254257
/*** (4) Gender bending copying ***/
255-
copy1.copy(&resp_hdr);
256-
comp_str = comp_http_hdr(&resp_hdr, &copy1);
257-
if (comp_str) {
258-
goto done;
258+
if (!comp_str) {
259+
copy1.copy(&resp_hdr);
260+
comp_str = comp_http_hdr(&resp_hdr, &copy1);
259261
}
260262

261-
copy2.copy(&req_hdr);
262-
comp_str = comp_http_hdr(&req_hdr, &copy2);
263-
if (comp_str) {
264-
goto done;
263+
if (!comp_str) {
264+
copy2.copy(&req_hdr);
265+
comp_str = comp_http_hdr(&req_hdr, &copy2);
265266
}
266267

267-
done:
268-
req_hdr.destroy();
269-
resp_hdr.destroy();
270-
copy1.destroy();
271-
copy2.destroy();
272-
273268
if (comp_str) {
274269
printf("FAILED: (test #%d) copy & compare: %s\n", testnum, comp_str);
275270
printf("REQ:\n[%.*s]\n", static_cast<int>(strlen(request)), request);
276271
printf("RESP :\n[%.*s]\n", static_cast<int>(strlen(response)), response);
277272
return (0);
278-
} else {
279-
return (1);
280273
}
274+
275+
return (1);
281276
}
282277

283278
int
@@ -379,10 +374,16 @@ test_http_hdr_print_and_copy_aux(int testnum, const char *request, const char *r
379374
{
380375
ParseResult err;
381376
HTTPHdr hdr;
377+
HTTPHdr new_hdr;
382378
HTTPParser parser;
383379
const char *start;
384380
const char *end;
385381

382+
ts::PostScript cleanup([&]() -> void {
383+
hdr.destroy();
384+
new_hdr.destroy();
385+
});
386+
386387
char prt_buf[2048];
387388
int prt_bufsize = sizeof(prt_buf);
388389
int prt_bufindex, prt_dumpoffset, prt_ret;
@@ -416,7 +417,7 @@ test_http_hdr_print_and_copy_aux(int testnum, const char *request, const char *r
416417
}
417418

418419
/*** (2) copy the request header ***/
419-
HTTPHdr new_hdr, marshal_hdr;
420+
HTTPHdr marshal_hdr;
420421
TestRefCountObj ref;
421422

422423
// Pretend to pin this object with a refcount.
@@ -524,9 +525,6 @@ test_http_hdr_print_and_copy_aux(int testnum, const char *request, const char *r
524525
return (0);
525526
}
526527

527-
hdr.destroy();
528-
new_hdr.destroy();
529-
530528
if (test_http_hdr_copy_over_aux(testnum, request, response) == 0) {
531529
return 0;
532530
}

0 commit comments

Comments
 (0)