[SERVER-53049] stdx::condition invariants and segfaults in unittest framework Created: 24/Nov/20  Updated: 27/Oct/23  Resolved: 24/Nov/20

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Billy Donahue Assignee: Backlog - Service Architecture
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File test.out    
Issue Links:
Related
related to SERVER-53035 provide a way to ASSERT from a non-ma... Closed
Assigned Teams:
Service Arch
Participants:

 Description   

While working on SERVER-53035 unittest::ThreadAssertionMonitor, it was found that stdx::condition_variable would segfault or hit invariants where std::condition would succeed reliably.

The segfaults and invariants were observed in the SharedFuture concurrency tests, which are the first clients of the ThreadAssertionMonitor.

There's a note in thread_assertion_monitor.h, next to the _cv variable about it.
Changing _cv back to stdx::condition_variable for experimentation should reproduce the bug. It was readily observable.

It's also possible that ThreadAssertionMonitor's use of _cv is incorrect somehow and we haven't thought about it hard enough to see how.



 Comments   
Comment by Billy Donahue [ 24/Nov/20 ]

This was a bug in the test.

Fixed before submission.

https://mongodbcr.appspot.com/720450002/diff2/739890011:711630001/src/mongo/util/future_test_shared_future.cpp

I think it's probably the case that stdx::condition_variable simply interacts with other threads in such a way as to exacerbate the bug more than std::condition_variable did.

Comment by Billy Donahue [ 24/Nov/20 ]

test.out is a sample failure.
Test is also observed to deadlock.

Generated at Thu Feb 08 05:29:47 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.