[SERVER-51061] Rename c preprocessor macro that guards access to invariant.h header. Created: 18/Sep/20  Updated: 29/Oct/23  Resolved: 04/May/21

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 5.0.0-rc0

Type: Task Priority: Major - P3
Reporter: Andy Schwerin Assignee: Sara Golemon
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-51062 Remove references to unconsulted prep... Closed
related to SERVER-51063 Rename C preprocessor macro that guar... Closed
is related to SERVER-56571 Remove invariant.h allowlist Closed
Backwards Compatibility: Fully Compatible
Sprint: Security 2021-05-03, Security 2021-05-17
Participants:

 Description   

The C preprocessor macro MONGO_INCLUDE_INVARIANT_H_WHITELISTED is used to identify headers that are allowed to directly include the file src/mongo/util/invariant.h. This ticket is to rename the macro to MONGO_ALLOW_INCLUDE_INVARIANT_H.

Folding in work from similar small tickets:

  • SERVER-51062 Remove references to unconsulted preprocessor macro MONGO_PCH_WHITELISTED
  • SERVER-51063 Rename C preprocessor macro that guards access to DNS query implementations


 Comments   
Comment by Githook User [ 04/May/21 ]

Author:

{'name': 'Sara Golemon', 'email': 'sara.golemon@mongodb.com', 'username': 'sgolemon'}

Message: SERVER-51061 Rename WHITELIST macros to ALLOW
Branch: master
https://github.com/mongodb/mongo/commit/bd75fc927ec6dbf8a5db6a0377b3b235453f4d71

Comment by Billy Donahue [ 03/May/21 ]

Ok. If it doesn't simplify your life, forget it.
I think it does get in the way of indexing tools and parse-caching strategies.
A separate ticket is fine. SERVER-56571

Comment by Sara Golemon [ 03/May/21 ]

According to the comment in invariant.h, the restriction isn't to prevent access to the header, it's just to make the negative effects of an include cycle less problematic for unwary callers.

I'll agree that we don't really need guardrails for that, but at the same time it doesn't seem to be getting in anyone's way and is potentially avoiding some issues for somebody.

If you feel strongly about this then I'd recommend filing a separate ticket for discussion of removing it, while we keep this one to a simple rename which addresses the work in the epic without preventing us from going more aggressive in the future.

Comment by Billy Donahue [ 30/Apr/21 ]

I think we should just get rid of the MONGO_INCLUDE_INVARIANT_H_WHITELISTED handshake.
Dozens of files get around it inadvertently by including string_data.h and getting a transitive include of invariant.h.
I don't think there's a technical reason for the restriction. If we just got rid of it we wouldn't be worse off.

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