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


##########
tests/gold_tests/pluginTest/regex_remap/regex_remap.test.py:
##########
@@ -123,12 +125,29 @@
 tr.Processes.Default.Streams.stdout = "gold/regex_remap_simple.gold"
 tr.StillRunningAfter = ts
 
-# 3 Test - Preserve the original crash guard from #5762. This request must
+# 3 Test - A 3 KB query redirects. This rule backtracks once per subject
+# character, so it used to exhaust the 32 KB stack PCRE2 falls back to when a
+# match context carries none, and the rule was skipped. The plugin's context 
now
+# inherits the shared 1 MB stack, so the rule matches and the redirect fires.
+tr = Test.AddTestRun("long query redirects rather than exhausting the JIT 
stack")
+creq = replay_txns[1]['client-request']
+tr.MakeCurlCommand(
+    curl_and_args + f"--header 'uuid: {creq['headers']['fields'][1][1]}' 
'{creq['url']}'" + " | grep -e '^HTTP/' -e '^Location'",
+    ts=ts)
+tr.Processes.Default.ReturnCode = 0
+tr.Processes.Default.Streams.stdout = "gold/regex_remap_redirect.gold"
+tr.StillRunningAfter = ts
+
+# 3b Test - Preserve the original crash guard from #5762. This request must
 # survive resource exhaustion without redirecting, regardless of which matching
-# resource limit is reached (JIT stack, match work, depth, or heap).
+# resource limit is reached (JIT stack, match work, depth, or heap). Against 
the
+# shared 1 MB stack this rule needs a subject past 43 KB to exhaust it, which 
is
+# why the request header limit is raised above. Shortening this query silently
+# turns the run into a plain redirect test.
+crash_guard_query = 'x' * 64000
 tr = Test.AddTestRun("resource exhaustion does not crash ATS")
-creq = replay_txns[1]['client-request']
-tr.MakeCurlCommand(curl_and_args + f"--header 'uuid: 
{creq['headers']['fields'][1][1]}' '{creq['url']}'", ts=ts)
+tr.MakeCurlCommand(
+    curl_and_args + "--header 'uuid: 180' " + 
f"'http://example.one/alpha/bravo/?action=newsfed;{crash_guard_query}'", ts=ts)

Review Comment:
   Please gate this crash-guard run on a JIT-capable PCRE2 build (or make its 
expected result conditional). `Regex::compile()` ignores a failed 
`pcre2_jit_compile`, and the new unit tests explicitly skip when 
`pattern_has_jit()` is false (src/tsutil/unit_tests/test_Regex.cc:1120-1122). 
Without JIT, this 64 KiB subject is interpreted instead of exhausting the 1 MiB 
JIT stack, so it follows the redirect and cannot match `regex_remap_crash.gold` 
or produce the resource-limit diagnostic, causing the AuTest to fail.



-- 
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