[Bug c++/99613] Static variable destruction order race condition

2021-09-11 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99613 Andrew Pinski changed: What|Removed |Added Target Milestone|--- |8.5

[Bug c++/99613] Static variable destruction order race condition

2021-04-22 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99613 Jakub Jelinek changed: What|Removed |Added Status|NEW |RESOLVED Assignee|unassigned

[Bug c++/99613] Static variable destruction order race condition

2021-04-22 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99613 --- Comment #21 from CVS Commits --- The releases/gcc-8 branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:bd2a59b7b3f049d81566163056ae1206d4fa3e6d commit r8-10896-gbd2a59b7b3f049d81566163056ae1206d4fa3e6d Author: Jakub Jelinek

[Bug c++/99613] Static variable destruction order race condition

2021-04-20 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99613 --- Comment #20 from CVS Commits --- The releases/gcc-9 branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:cb6efb9d909323e41fa0a8abbe805eb32d1659ea commit r9-9432-gcb6efb9d909323e41fa0a8abbe805eb32d1659ea Author: Jakub Jelinek

[Bug c++/99613] Static variable destruction order race condition

2021-03-19 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99613 --- Comment #19 from CVS Commits --- The releases/gcc-10 branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:1703937a05b8b95bc29d2de292387dfd9eb7c9a3 commit r10-9487-g1703937a05b8b95bc29d2de292387dfd9eb7c9a3 Author: Jakub Jelinek

[Bug c++/99613] Static variable destruction order race condition

2021-03-16 Thread cvs-commit at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99613 --- Comment #18 from CVS Commits --- The master branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:0251051db64f13c9a31a05c8133c31dc50b2b235 commit r11-7696-g0251051db64f13c9a31a05c8133c31dc50b2b235 Author: Jakub Jelinek Date:

[Bug c++/99613] Static variable destruction order race condition

2021-03-16 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99613 --- Comment #17 from Richard Biener --- I think for the non-dependent case there's no good fix but the standard can be read in a way that only the dependent case has well-defined order of destruction.

[Bug c++/99613] Static variable destruction order race condition

2021-03-16 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99613 --- Comment #16 from Jakub Jelinek --- Created attachment 50399 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50399=edit gcc11-pr99613.patch Untested patch that swaps the two calls.

[Bug c++/99613] Static variable destruction order race condition

2021-03-16 Thread jacobhemstad at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99613 Jake Hemstad changed: What|Removed |Added CC||jacobhemstad at gmail dot com ---

[Bug c++/99613] Static variable destruction order race condition

2021-03-16 Thread michalz at nvidia dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99613 --- Comment #14 from Michal Zientkiewicz --- https://eel.is/c++draft/basic.start.term#3 If the completion of the constructor or dynamic initialization of an object with static storage duration strongly happens before that of another, the

[Bug c++/99613] Static variable destruction order race condition

2021-03-16 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99613 Jakub Jelinek changed: What|Removed |Added CC||jason at gcc dot gnu.org --- Comment

[Bug c++/99613] Static variable destruction order race condition

2021-03-16 Thread michalz at nvidia dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99613 --- Comment #12 from Michal Zientkiewicz --- As a side note - Clang emits the call to atexit between acquire and release and the last demo works fine when compiled with Clang, but not GCC.

[Bug c++/99613] Static variable destruction order race condition

2021-03-16 Thread michalz at nvidia dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99613 --- Comment #11 from Michal Zientkiewicz --- Created attachment 50396 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50396=edit Demo with dependent variables I added a new demo which shows that dependent variable gets destroyed after its

[Bug c++/99613] Static variable destruction order race condition

2021-03-16 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99613 --- Comment #10 from Jakub Jelinek --- Even the swapping of the two calls would be IMHO a significant slowdown. Because __cxa_atexit under the hood holds a global lock (fortunately not across the duration of the whole user ctor, but across the

[Bug c++/99613] Static variable destruction order race condition

2021-03-16 Thread michalz at nvidia dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99613 --- Comment #9 from Michal Zientkiewicz --- (My previous comment may seem unclear, so let me clarify): The _demo_ is not very useful, but the example in the example from the previous comment is.

[Bug c++/99613] Static variable destruction order race condition

2021-03-16 Thread michalz at nvidia dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99613 --- Comment #8 from Michal Zientkiewicz --- Jakub: You read coorectly, I was checking for global construction/destruction order of many variables. I agree that a global lock is a heavy-handed solution - and likely the only one that would always

[Bug c++/99613] Static variable destruction order race condition

2021-03-16 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99613 --- Comment #7 from Jakub Jelinek --- Swapping __cxa_guard_release with __cxa_atexit would "fix" the case where the user program would in all threads access all the local variables in the same order. So all threads first access f<0>(), then

[Bug c++/99613] Static variable destruction order race condition

2021-03-16 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99613 --- Comment #6 from Richard Biener --- (In reply to Jakub Jelinek from comment #3) > Or do you mean it is possible that for two unrelated variables > variable 1 with its guard variable 2 with its guard > __cxa_guard_acquire succeeds >

[Bug c++/99613] Static variable destruction order race condition

2021-03-16 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99613 --- Comment #5 from Jakub Jelinek --- The variables can be constructed even exactly at the same time, or at least the ctors can be started concurrently and end concurrently. I don't think you can rely on a particular ordering of the destructors

[Bug c++/99613] Static variable destruction order race condition

2021-03-16 Thread michalz at nvidia dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99613 --- Comment #4 from Michal Zientkiewicz --- The problem is that the order of destruction is incorrect if there's a race condition. Consider 2 threads initializing static variables S1 and S2: Thread A Thread B acquire construct S1

[Bug c++/99613] Static variable destruction order race condition

2021-03-16 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99613 Jakub Jelinek changed: What|Removed |Added CC||redi at gcc dot gnu.org --- Comment #3

[Bug c++/99613] Static variable destruction order race condition

2021-03-16 Thread jakub at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99613 Jakub Jelinek changed: What|Removed |Added CC||jakub at gcc dot gnu.org --- Comment #2

[Bug c++/99613] Static variable destruction order race condition

2021-03-16 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99613 Richard Biener changed: What|Removed |Added Status|UNCONFIRMED |NEW Known to fail|