public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug analyzer/108709] New: FAIL: gcc.dg/analyzer/pipe-glibc.c
@ 2023-02-08  6:13 nightstrike at gmail dot com
  2023-02-08  6:22 ` [Bug testsuite/108709] " nightstrike at gmail dot com
  0 siblings, 1 reply; 2+ messages in thread
From: nightstrike at gmail dot com @ 2023-02-08  6:13 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 108709
           Summary: FAIL: gcc.dg/analyzer/pipe-glibc.c
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: nightstrike at gmail dot com
  Target Milestone: ---

This test fails on Windows for lack of fork.  It actually fails for not having
pipe(), also, but _pipe() does the job well enough, so that fix is a simple
#define.  It is not very apparent what the test is doing, since it doesn't get
executed and doesn't appear to have analyzer calls, but the following poor
man's solution does result in a test that executes correctly on
x86_64-redhat-linux (EL8) and x86_64-w64-mingw32 under Wine.

git diff ../gcc/testsuite/gcc.dg/analyzer/pipe-glibc.c
diff --git a/gcc/testsuite/gcc.dg/analyzer/pipe-glibc.c
b/gcc/testsuite/gcc.dg/analyzer/pipe-glibc.c
index a8546ea9549..3b93212f56d 100644
--- a/gcc/testsuite/gcc.dg/analyzer/pipe-glibc.c
+++ b/gcc/testsuite/gcc.dg/analyzer/pipe-glibc.c
@@ -30,6 +30,30 @@ write_to_pipe (int file)
   fclose (stream);
 }

+#ifdef WIN32
+// Use native _pipe with a thread on windows, as forks don't exist
+// This requires that the pipes remain open, so disable close()
+
+#include <io.h>
+#include <fcntl.h>
+#define pipe(FD) _pipe(FD, 256, O_BINARY)
+#define close(X)
+
+#include <windows.h>
+#include <process.h>
+static __cdecl void
+fake_fork (void * arg)
+{
+    int * mypipe = arg;
+    read_from_pipe (mypipe[0]);
+}
+
+#define fork() _beginthread(fake_fork, 0, mypipe)
+#define wait(X) WaitForSingleObject((void *)pid, INFINITE)
+#else
+#include <sys/wait.h>
+#endif
+
 int
 main (void)
 {
@@ -66,6 +90,7 @@ main (void)
          Close other end first. */
       close (mypipe[0]);
       write_to_pipe (mypipe[1]);
+      wait(NULL);
       return EXIT_SUCCESS;
     }
 }

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

* [Bug testsuite/108709] FAIL: gcc.dg/analyzer/pipe-glibc.c
  2023-02-08  6:13 [Bug analyzer/108709] New: FAIL: gcc.dg/analyzer/pipe-glibc.c nightstrike at gmail dot com
@ 2023-02-08  6:22 ` nightstrike at gmail dot com
  0 siblings, 0 replies; 2+ messages in thread
From: nightstrike at gmail dot com @ 2023-02-08  6:22 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from nightstrike <nightstrike at gmail dot com> ---
Perhaps these are separate bugs, but:

1) gcc.dg/analyzer/pipe-manpages.c will need similar improvements

2) gcc.dg/analyzer/pipe-void-return.c passes with an incorrect declaration for
pipe(), implying that we won't test whether it captures using uninitialized
file descriptors when _pipe() fails

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

end of thread, other threads:[~2023-02-08  6:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-08  6:13 [Bug analyzer/108709] New: FAIL: gcc.dg/analyzer/pipe-glibc.c nightstrike at gmail dot com
2023-02-08  6:22 ` [Bug testsuite/108709] " nightstrike at gmail dot com

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).