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

Add clang rule to detect access to deleted pointers

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 6.0 Desired
    • Component/s: None
    • Labels:
      None

      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 . Andrew Morrow 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

            Assignee:
            backlog-server-devplatform Backlog - Server Development Platform Team (SDP)
            Reporter:
            pierlauro.sciarelli Pierlauro Sciarelli
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: