Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-53775

Add clang rule to detect access to deleted pointers

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Unresolved
    • Icon: Major - P3 Major - P3
    • 6.0 Desired
    • None
    • None
    • None
    • Service Arch

    Description

      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.

      Attachments

        Activity

          People

            backlog-server-servicearch Backlog - Service Architecture
            pierlauro.sciarelli@mongodb.com Pierlauro Sciarelli
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: