[SERVER-70397] Look into disabling self-move assignment assertion in g++ Created: 10/Oct/22 Updated: 14/Dec/22 Resolved: 14/Dec/22 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Ivan Fefer | Assignee: | [DO NOT ASSIGN] Backlog - Server Development Platform Team (SDP) (Inactive) |
| Resolution: | Won't Fix | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||
| Assigned Teams: |
Server Development Platform
|
||||
| Participants: | |||||
| Description |
|
Currently when we do a self-move assignment or a self-swap with std::swap, our code will fail in debug mode. There is a detailed discussion about this assertion on StackOverflow: https://stackoverflow.com/questions/22915325/avoiding-self-assignment-in-stdshuffle We should research a possibility to disable it with `__glibcxx_check_self_move_assign`. |
| Comments |
| Comment by Alex Neben [ 14/Dec/22 ] |
|
v4 rollout is complete this should no longer cause problems |
| Comment by Andrew Morrow (Inactive) [ 19/Oct/22 ] |
|
I don't think the basic.h approach would work. While we do forceinclude basic.h for everything under src/mongo, we don't do that for things under src/third_party. We would need to check whether compiling different TUs with different settings for __glibcxx_check_self_move_assign and then linking them results in an ODR violation or not, but it sounds very likely it would. We could potentially add a new forceinclude file that was used for third party to address that. |
| Comment by Alex Neben [ 19/Oct/22 ] |
|
The approach outlined in the ticket does not work since it requires a very special order of includes. This is fixed in a newer version of debug mode so imho we can just wait until the toolchain v4 rollout. For a working solution we can use https://evergreen.mongodb.com/patch/631a7c3f1e2d175fb4f7efd3?redirect_spruce_users=true or |