Skip to content

[PD-Disagg] Fix double free when prebuilt batch is aborted.#18822

Merged
hnyls2002 merged 2 commits intomainfrom
lsyin/try-fix-double-free-pd-disagg
Feb 14, 2026
Merged

[PD-Disagg] Fix double free when prebuilt batch is aborted.#18822
hnyls2002 merged 2 commits intomainfrom
lsyin/try-fix-double-free-pd-disagg

Conversation

@hnyls2002
Copy link
Collaborator

@hnyls2002 hnyls2002 commented Feb 14, 2026

Fix the issue: #17797

How to reproduce this bug (it only happens when grammar hit exception):

--- a/python/sglang/srt/disaggregation/decode_schedule_batch_mixin.py
+++ b/python/sglang/srt/disaggregation/decode_schedule_batch_mixin.py
@@ -110,6 +110,14 @@ class ScheduleBatchDisaggregationDecodeMixin:
         for req in self.reqs:
             self.output_ids.append(req.output_ids[-1])
             self.tree_cache.cache_unfinished_req(req)
+            from mock import Mock
+
+            # mock a exception grammar
+            req.grammar = Mock()
+            req.grammar.current_token = None
+            req.grammar.accept_token = Mock()
+            req.grammar.accept_token.side_effect = ValueError("Test Grammar Failures")
+            req.grammar.finished = Mock()
             if req.grammar is not None:
                 # FIXME: this try-except block is for handling unexpected xgrammar issue.
                 try:

Do this custom patch to the code base and launch a PD-disaggregation server, then it will enter the double free code path (but now it will raise another error of by mamba check)

@gemini-code-assist
Copy link
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@hnyls2002
Copy link
Collaborator Author

/tag-and-rerun-ci

@hnyls2002 hnyls2002 merged commit 4474fb9 into main Feb 14, 2026
85 of 136 checks passed
@hnyls2002 hnyls2002 deleted the lsyin/try-fix-double-free-pd-disagg branch February 14, 2026 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant