binutils Newspaper
OCTOBER 6, 2026
gas — Proposed — Sentiment 7 / 10

gas: testsuite: How to fix gas/all/pr27381 on Windows?

Discussion on how to fix a failing gas testcase (pr27381) on Windows due to differences in `fopen` and `fstat` behavior compared to POSIX systems.

Jan Dubiec is seeking community input on how to fix the gas/all/pr27381 test case, which fails on Windows. The failure stems from platform-specific behavior of fopen and subsequent fstat calls when handling file paths, leading to different error messages and control flow than on POSIX systems. Three potential solutions are proposed: XFAILing the test on Windows, adjusting the expected regular expression, or adopting a more involved approach by checking file types with stat before opening.

In the Thread 2 participants
  1. Jan Dubiec <jdx@o2.pl> proposer

    Asks for community advice on fixing a failing gas testcase on Windows, presenting three potential solutions.

    “This test case fails on Windows because the following code from gas/read.c: [...] FILE * f = fopen (filename, FOPEN_RB); [...] returns NULL on Windows and non-NULL value on POSIX-compliant systems (assuming that filename exists and refers to a directory).”
  2. Jan Beulich <jbeulich@suse.com> reviewer

    Acknowledges the problem description regarding `fopen` and `fstat` behavior differences on Windows.

    “On 21.09.2026 14:53, Jan Dubiec wrote: > This test case fails on Windows because the following code from gas/read.c: > > [...] FILE * > search_and_open (const char *filename, char *path) > { > FILE *f = fopen (filename, FOPEN_RB); > [...] > > returns NULL on Windows and non-NULL value on POSIX-compliant systems > (assuming that filename exists and refers to a directory).”

Technical Tradeoffs

  • XFAILing the test sacrifices correctness verification on Windows.
  • Modifying the regex is a minimal change but might mask other issues.
  • Adding a `stat` check before `fopen` increases code complexity but improves cross-platform robustness.

In Details

The gas/all/pr27381 test case in Binutils is failing on Windows due to differences in how fopen and fstat interact with directory paths across platforms. On POSIX systems, fopen might return a valid file pointer for a directory, which fstat then correctly identifies as non-regular. On Windows, fopen is more restrictive and returns NULL for directories, leading to a different error path. The core of the issue is platform-specific file handling in search_and_open and subsequent validation in s_incbin. The RFC explores options ranging from simply marking the test as expected to…

For Context
gas
The GNU Assembler, part of the GNU Binutils package, which translates assembly language into object files.
testsuite
A collection of tests designed to verify the correctness of software.
pr27381
A specific problem report (likely from a bug tracking system) number 27381, which this test case aims to address or verify.
Windows
Microsoft's proprietary graphical operating system.
POSIX
Portable Operating System Interface, a family of standards specified by the IEEE for maintaining compatibility between operating systems.
fopen
A C standard library function that opens a file stream.
fstat
A C standard library function that retrieves file status information.
S_ISREG
A macro that checks if a stat structure's mode indicates a regular file.
S_ISDIR
A macro that checks if a stat structure's mode indicates a directory.
Filed Under: gasWindowsportabilitytestsuitefile handling