Copilot commented on code in PR #3587:
URL: https://github.com/apache/brpc/pull/3587#discussion_r4208091697
##########
test/bthread_priority_queue_unittest.cpp:
##########
@@ -246,4 +247,75 @@ TEST_F(PriorityQueueTest, multiple_eds_concurrent_preempt)
{
ASSERT_EQ((size_t)TOTAL, g_executed_ids.size());
}
+// Reuse the frames left by bthread_start_urgent instead of leaving the
+// scheduler's on-stack ReadyToRunArgs intact after the parent resumes.
+NOINLINE void reuse_stack_after_start_urgent() {
+ bthread_tag_t tags[256];
+ for (int& tag : tags) {
+ tag = BTHREAD_TAG_INVALID;
+ }
+}
Review Comment:
This helper's only effect is writing a non-volatile local array that is
never observed, so an optimizing compiler may reduce it to a no-op even though
it is marked `NOINLINE`. In that build the test does not actually overwrite the
parent's `ReadyToRunArgs` stack frame and can pass without exercising the
reported race; make the writes volatile or otherwise expose an observable
result.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]