-
Type: Task
-
Resolution: Unresolved
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
Server Programmability
benety.goh noticed that XCode 12.3 with the option -Wdangling-gsl was able to spot an unsafe unique pointer usage in resharding_recipient_service.cpp:
// UNSAFE because opCtx will then be an OperationContext* to a deleted OperationContext auto opCtx = cc().makeOperationContext().get(); auto catalogCache = Grid::get(opCtx)->catalogCache(); catalogCache->getShardedCollectionRoutingInfo(opCtx, _recipientDoc.getNss());
// SAFE auto opCtx = cc().makeOperationContext(); auto catalogCache = Grid::get(opCtx.get())->catalogCache(); catalogCache->getShardedCollectionRoutingInfo(opCtx.get(), _recipientDoc.getNss());
It would be good to add a clang check equivalent to -Wdangling-gsl , probably bugprone-dangling-handle could make the trick but it requires configuring HandleClasses . acm also pointed out that we could start using a clang-tidy configuration file (e.g. as done by envoyproxy) instead of manually passing the parameters.