public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/98386] New: C++20 module: file exists failure and success happen alternatively for windows.
@ 2020-12-19  3:11 unlvsur at live dot com
  2020-12-19  3:13 ` [Bug c++/98386] " unlvsur at live dot com
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: unlvsur at live dot com @ 2020-12-19  3:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98386

            Bug ID: 98386
           Summary: C++20 module: file exists failure and success happen
                    alternatively for windows.
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: unlvsur at live dot com
  Target Milestone: ---

D:\Desktop\module>g++ -c main.cc -Ofast -std=c++20 -s -flto -fmodules-ts
-march=native

D:\Desktop\module>g++ -c hello.cc -Ofast -std=c++20 -s -flto -fmodules-ts
-march=native
hello.cc:4:8: error: failed to write compiled module: File exists
    4 | export module hello;
      |        ^~~~~~
hello.cc:4:8: note: compiled module file is 'gcm.cache/hello.gcm'

D:\Desktop\module>g++ -c hello.cc -Ofast -std=c++20 -s -flto -fmodules-ts
-march=native

D:\Desktop\module>g++ -c hello.cc -Ofast -std=c++20 -s -flto -fmodules-ts
-march=native
hello.cc:4:8: error: failed to write compiled module: File exists
    4 | export module hello;
      |        ^~~~~~
hello.cc:4:8: note: compiled module file is 'gcm.cache/hello.gcm'

D:\Desktop\module>g++ -c hello.cc -Ofast -std=c++20 -s -flto -fmodules-ts
-march=native

D:\Desktop\module>g++ -c hello.cc -Ofast -std=c++20 -s -flto -fmodules-ts
-march=native
hello.cc:4:8: error: failed to write compiled module: File exists
    4 | export module hello;
      |        ^~~~~~
hello.cc:4:8: note: compiled module file is 'gcm.cache/hello.gcm'


You have a succ-error-succ-error loop. It must be something bugged here.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/98386] C++20 module: file exists failure and success happen alternatively for windows.
  2020-12-19  3:11 [Bug c++/98386] New: C++20 module: file exists failure and success happen alternatively for windows unlvsur at live dot com
@ 2020-12-19  3:13 ` unlvsur at live dot com
  2020-12-19  3:18 ` unlvsur at live dot com
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: unlvsur at live dot com @ 2020-12-19  3:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98386

--- Comment #1 from cqwrteur <unlvsur at live dot com> ---
Created attachment 49805
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49805&action=edit
bugged image

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/98386] C++20 module: file exists failure and success happen alternatively for windows.
  2020-12-19  3:11 [Bug c++/98386] New: C++20 module: file exists failure and success happen alternatively for windows unlvsur at live dot com
  2020-12-19  3:13 ` [Bug c++/98386] " unlvsur at live dot com
@ 2020-12-19  3:18 ` unlvsur at live dot com
  2020-12-21 17:06 ` nathan at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: unlvsur at live dot com @ 2020-12-19  3:18 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98386

--- Comment #2 from cqwrteur <unlvsur at live dot com> ---
My build of GCC for Windows can be found here.

https://github.com/expnkx/mingw-gcc

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/98386] C++20 module: file exists failure and success happen alternatively for windows.
  2020-12-19  3:11 [Bug c++/98386] New: C++20 module: file exists failure and success happen alternatively for windows unlvsur at live dot com
  2020-12-19  3:13 ` [Bug c++/98386] " unlvsur at live dot com
  2020-12-19  3:18 ` unlvsur at live dot com
@ 2020-12-21 17:06 ` nathan at gcc dot gnu.org
  2020-12-21 17:11 ` nathan at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: nathan at gcc dot gnu.org @ 2020-12-21 17:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98386

--- Comment #3 from Nathan Sidwell <nathan at gcc dot gnu.org> ---
Hm does rename(2) fail on windows if the new name exists?  (in posix it
replaces, otherwise there's gonna be a race condition)

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/98386] C++20 module: file exists failure and success happen alternatively for windows.
  2020-12-19  3:11 [Bug c++/98386] New: C++20 module: file exists failure and success happen alternatively for windows unlvsur at live dot com
                   ` (2 preceding siblings ...)
  2020-12-21 17:06 ` nathan at gcc dot gnu.org
@ 2020-12-21 17:11 ` nathan at gcc dot gnu.org
  2020-12-21 17:12 ` unlvsur at live dot com
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: nathan at gcc dot gnu.org @ 2020-12-21 17:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98386

--- Comment #4 from Nathan Sidwell <nathan at gcc dot gnu.org> ---
Created attachment 49823
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49823&action=edit
test patch

This does an unlink before the rename, and also adds more logging.  If it
fails, please try with -fdump-lang-module added and provide that dump

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/98386] C++20 module: file exists failure and success happen alternatively for windows.
  2020-12-19  3:11 [Bug c++/98386] New: C++20 module: file exists failure and success happen alternatively for windows unlvsur at live dot com
                   ` (3 preceding siblings ...)
  2020-12-21 17:11 ` nathan at gcc dot gnu.org
@ 2020-12-21 17:12 ` unlvsur at live dot com
  2020-12-21 17:14 ` nathan at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: unlvsur at live dot com @ 2020-12-21 17:12 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98386

--- Comment #5 from cqwrteur <unlvsur at live dot com> ---
(In reply to Nathan Sidwell from comment #4)
> Created attachment 49823 [details]
> test patch
> 
> This does an unlink before the rename, and also adds more logging.  If it
> fails, please try with -fdump-lang-module added and provide that dump

unlink and rename is a TOCTOU security vulnerability. The correct method must
use openat and NtCreateFile.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/98386] C++20 module: file exists failure and success happen alternatively for windows.
  2020-12-19  3:11 [Bug c++/98386] New: C++20 module: file exists failure and success happen alternatively for windows unlvsur at live dot com
                   ` (4 preceding siblings ...)
  2020-12-21 17:12 ` unlvsur at live dot com
@ 2020-12-21 17:14 ` nathan at gcc dot gnu.org
  2020-12-21 17:35 ` unlvsur at live dot com
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: nathan at gcc dot gnu.org @ 2020-12-21 17:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98386

Nathan Sidwell <nathan at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2020-12-21

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/98386] C++20 module: file exists failure and success happen alternatively for windows.
  2020-12-19  3:11 [Bug c++/98386] New: C++20 module: file exists failure and success happen alternatively for windows unlvsur at live dot com
                   ` (5 preceding siblings ...)
  2020-12-21 17:14 ` nathan at gcc dot gnu.org
@ 2020-12-21 17:35 ` unlvsur at live dot com
  2020-12-21 17:43 ` nathan at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: unlvsur at live dot com @ 2020-12-21 17:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98386

--- Comment #6 from cqwrteur <unlvsur at live dot com> ---
(In reply to Nathan Sidwell from comment #3)
> Hm does rename(2) fail on windows if the new name exists?  (in posix it
> replaces, otherwise there's gonna be a race condition)

well. tbh, on windows, the safest way to deal with filesystem is to use NT
syscalls. Or you will not be able to access at-series apis.

C++17 filesystem is a horrible mistake since every C++17 filesystem use case is
a TOCTOU

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/98386] C++20 module: file exists failure and success happen alternatively for windows.
  2020-12-19  3:11 [Bug c++/98386] New: C++20 module: file exists failure and success happen alternatively for windows unlvsur at live dot com
                   ` (6 preceding siblings ...)
  2020-12-21 17:35 ` unlvsur at live dot com
@ 2020-12-21 17:43 ` nathan at gcc dot gnu.org
  2020-12-21 17:45 ` unlvsur at live dot com
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: nathan at gcc dot gnu.org @ 2020-12-21 17:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98386

--- Comment #7 from Nathan Sidwell <nathan at gcc dot gnu.org> ---
Please take your diatribes to /dev/null.  Are you able to test the patch?

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/98386] C++20 module: file exists failure and success happen alternatively for windows.
  2020-12-19  3:11 [Bug c++/98386] New: C++20 module: file exists failure and success happen alternatively for windows unlvsur at live dot com
                   ` (7 preceding siblings ...)
  2020-12-21 17:43 ` nathan at gcc dot gnu.org
@ 2020-12-21 17:45 ` unlvsur at live dot com
  2020-12-21 17:46 ` unlvsur at live dot com
  2020-12-21 17:51 ` nathan at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: unlvsur at live dot com @ 2020-12-21 17:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98386

--- Comment #8 from cqwrteur <unlvsur at live dot com> ---
(In reply to Nathan Sidwell from comment #7)
> Please take your diatribes to /dev/null.  Are you able to test the patch?

Wait a second. I am testing

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/98386] C++20 module: file exists failure and success happen alternatively for windows.
  2020-12-19  3:11 [Bug c++/98386] New: C++20 module: file exists failure and success happen alternatively for windows unlvsur at live dot com
                   ` (8 preceding siblings ...)
  2020-12-21 17:45 ` unlvsur at live dot com
@ 2020-12-21 17:46 ` unlvsur at live dot com
  2020-12-21 17:51 ` nathan at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: unlvsur at live dot com @ 2020-12-21 17:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98386

--- Comment #9 from cqwrteur <unlvsur at live dot com> ---
(In reply to Nathan Sidwell from comment #7)
> Please take your diatribes to /dev/null.  Are you able to test the patch?

fixed confirm

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c++/98386] C++20 module: file exists failure and success happen alternatively for windows.
  2020-12-19  3:11 [Bug c++/98386] New: C++20 module: file exists failure and success happen alternatively for windows unlvsur at live dot com
                   ` (9 preceding siblings ...)
  2020-12-21 17:46 ` unlvsur at live dot com
@ 2020-12-21 17:51 ` nathan at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: nathan at gcc dot gnu.org @ 2020-12-21 17:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98386

Nathan Sidwell <nathan at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|WAITING                     |RESOLVED

--- Comment #10 from Nathan Sidwell <nathan at gcc dot gnu.org> ---
e798f081925 2020-12-21 | c++: Windows rename [PR 98412]

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-12-21 17:51 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-19  3:11 [Bug c++/98386] New: C++20 module: file exists failure and success happen alternatively for windows unlvsur at live dot com
2020-12-19  3:13 ` [Bug c++/98386] " unlvsur at live dot com
2020-12-19  3:18 ` unlvsur at live dot com
2020-12-21 17:06 ` nathan at gcc dot gnu.org
2020-12-21 17:11 ` nathan at gcc dot gnu.org
2020-12-21 17:12 ` unlvsur at live dot com
2020-12-21 17:14 ` nathan at gcc dot gnu.org
2020-12-21 17:35 ` unlvsur at live dot com
2020-12-21 17:43 ` nathan at gcc dot gnu.org
2020-12-21 17:45 ` unlvsur at live dot com
2020-12-21 17:46 ` unlvsur at live dot com
2020-12-21 17:51 ` nathan at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).