Skip to content

[tokenizer] Guard communicator handle_recv against stale messages#23804

Open
brucechanglongxu wants to merge 1 commit intosgl-project:mainfrom
brucechanglongxu:msi/upstream-communicator-null-guard
Open

[tokenizer] Guard communicator handle_recv against stale messages#23804
brucechanglongxu wants to merge 1 commit intosgl-project:mainfrom
brucechanglongxu:msi/upstream-communicator-null-guard

Conversation

@brucechanglongxu
Copy link
Copy Markdown
Contributor

This PR fixes a race in tokenizer communicator receive handling. Late messages can arrive after watching-call cleanup; previously that path could append into cleared state and throw. I added a guard in handle_recv so it only processes messages when active watch state exists, plus a regression test that reproduces the late-message case and verifies no crash. Local test run: /usr/bin/python3 -m unittest discover -s test/registered/tokenizer -p test_tokenizer_communicator.py -v (pass).

Motivation

Fix a race in tokenizer communicator receive handling. Late messages can arrive after a watch call has already cleaned up internal state. Previously, that path could try to append into cleared state and throw.

Modifications

  1. Added a guard in handle_recv so it only appends/signals when active watch state exists.
  2. Added a regression test that completes a watch call, sends a late stale message, and verifies no crash.

Accuracy Tests

Ran:

/usr/bin/python3 -m unittest discover -s test/registered/tokenizer -p test_tokenizer_communicator.py -v

Pass:

test_handle_recv_ignores_stale_message_after_watch_completes

Speed Tests and Profiling

Not applicable. This is a control-flow safety fix only.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Warning

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

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.

1 participant