[SERVER-39392] Invariant in PlanStage::dispose always evaluates as true Created: 06/Feb/19  Updated: 29/Oct/23  Resolved: 14/Aug/20

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: None
Fix Version/s: 4.4.1, 3.6.20, 4.7.0, 4.0.21

Type: Bug Priority: Major - P3
Reporter: Anton Korshunov Assignee: Andrew Morrow (Inactive)
Resolution: Fixed Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
depends on SERVER-47598 locally installed mongodbtoolchains c... Closed
Related
is related to SERVER-47598 locally installed mongodbtoolchains c... Closed
is related to SERVER-37453 Delete PlanStage::dispose() Closed
Backwards Compatibility: Fully Compatible
Operating System: ALL
Backport Requested:
v4.4, v4.2, v4.0, v3.6
Sprint: Dev Platform 2020-08-24
Participants:

 Description   

Due to a typo in the PlanStage::dispose() invariant it can never be evaluated to false.

src/mongo/db/exec/plan_stage.h:271:62: warning: self-comparison always evaluates to true [-Wtautological-compare]
 
            ::mongo::invariantWithLocation((!_opCtx !_opCtx || opCtx == opCtx", "src/mongo/db/exec/plan_stage.h", 271);

The opCtx == opCtx condition should be opCtx == _optCtx.

Note that there is a task SERVER-37453 to delete PlantExecutor::dispose() method and its friends, so we may not need to fix this issue if the dispose() code is being removed in next sprint.



 Comments   
Comment by Githook User [ 17/Aug/20 ]

Author:

{'name': 'Andrew Morrow', 'email': 'acm@mongodb.com', 'username': 'acmorrow'}

Message: SERVER-39392 Remove tautological invariant

(cherry picked from commit e908bb6b444235cb251c4e69b5adac9e6a983953)
(cherry picked from commit fcf1e05d5c1a4df7ac4cbdf71950ee226d1e35d0)
(cherry picked from commit 179d4953d8d1c1018dc238aa0824a4a2c4e2f5fd)
(cherry picked from commit 00cc5c686de7afbd6c6e275ba42f2b385084ee71)
Branch: v3.6
https://github.com/mongodb/mongo/commit/afeaf1aa3b84953c2582c10bde12c92107040d47

Comment by Githook User [ 17/Aug/20 ]

Author:

{'name': 'Andrew Morrow', 'email': 'acm@mongodb.com', 'username': 'acmorrow'}

Message: SERVER-39392 Remove tautological invariant

(cherry picked from commit e908bb6b444235cb251c4e69b5adac9e6a983953)
(cherry picked from commit fcf1e05d5c1a4df7ac4cbdf71950ee226d1e35d0)
(cherry picked from commit 179d4953d8d1c1018dc238aa0824a4a2c4e2f5fd)
Branch: v4.0
https://github.com/mongodb/mongo/commit/00cc5c686de7afbd6c6e275ba42f2b385084ee71

Comment by Githook User [ 17/Aug/20 ]

Author:

{'name': 'Andrew Morrow', 'email': 'acm@mongodb.com', 'username': 'acmorrow'}

Message: SERVER-39392 Remove tautological invariant

(cherry picked from commit e908bb6b444235cb251c4e69b5adac9e6a983953)
(cherry picked from commit fcf1e05d5c1a4df7ac4cbdf71950ee226d1e35d0)
Branch: v4.2
https://github.com/mongodb/mongo/commit/179d4953d8d1c1018dc238aa0824a4a2c4e2f5fd

Comment by Githook User [ 17/Aug/20 ]

Author:

{'name': 'Andrew Morrow', 'email': 'acm@mongodb.com', 'username': 'acmorrow'}

Message: SERVER-39392 Remove tautological invariant

(cherry picked from commit e908bb6b444235cb251c4e69b5adac9e6a983953)
Branch: v4.4
https://github.com/mongodb/mongo/commit/fcf1e05d5c1a4df7ac4cbdf71950ee226d1e35d0

Comment by Githook User [ 14/Aug/20 ]

Author:

{'name': 'Andrew Morrow', 'email': 'acm@mongodb.com', 'username': 'acmorrow'}

Message: SERVER-39392 Remove tautological invariant
Branch: master
https://github.com/mongodb/mongo/commit/e908bb6b444235cb251c4e69b5adac9e6a983953

Comment by Andrew Morrow (Inactive) [ 13/Aug/20 ]

Code review URL: https://mongodbcr.appspot.com/637460002/

Comment by Andrew Morrow (Inactive) [ 13/Aug/20 ]

This has become a blocker for SERVER-47598. anton.korshunov - do you mind if I claim this ticket, since it is a one line deletion?

Comment by Andrew Morrow (Inactive) [ 05/Aug/20 ]

I'd like to re-open this issue: the indicated code has not yet been removed for other reasons, as was used as a justification for not fixing the issue. The incorrect code does cause issues in practice. We don't see this warning become an error in normal builds because for whatever reason GCC can't see the tautology when it is wrapped in a macro. However, certain combinations of tools like ccache and icecream can alter the preprocessing setup such that the compiler does see the tautology, resulting in failed builds. A future compiler that was better at understanding macro expansions could also begin to issue errors at any time. The fix is trivial, because not only is the invariant tautological, but it is entirely unnecessary due to the assignment immediately before it.

Comment by Kelsey Schubert [ 06/Feb/19 ]

It looks like it's been this way since 3.6, do we need to consider backports?

Generated at Thu Feb 08 04:51:55 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.