Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stat() on Windows filesystem path fails with EOVERFLOW for 32-bit process #6603

Closed
doxxx opened this issue Mar 1, 2021 · 3 comments
Closed

Comments

@doxxx
Copy link

doxxx commented Mar 1, 2021

Environment

Windows build number: Microsoft Windows [Version 10.0.19042.804]
Your Distribution version: Ubuntu 20.04
Whether the issue is on WSL 2 and/or WSL 1: WSL 2

Steps to reproduce

With the distribution GCC installed (in this case GCC 9 it seems), compile the following C program using the GCC -m32 flag in WSL2:

Source: https://gist.github.com/doxxx/e93136c1a95582ad92da96723fd1c073
Compile command: gcc -m32 wsl-stat-failure.c

Once compiled, change directory to /mnt/c or equivalent for your system in WSL and run the compiled program. It should print the failure message. For example:

gtyler@GTYLER:/mnt/c$ ~/tmp/a.out
stat(/mnt/c) != 0, errno=75

Strace log for the failure: https://gist.github.com/doxxx/f205cf8f6b4ad7daa327af7ddb224f20

For comparison, change directories to a non-Windows filesystem like /tmp and run it again. It should print the success message. For example:

gtyler@GTYLER:/tmp$ ~/tmp/a.out
stat(/tmp) succeeded

When compiled without the -m32 flag, the stat call succeeds for a Windows filesystem path. Strace log for the success with 64-bit process: https://gist.github.com/doxxx/56352ea3a647f25e77dfad240f265325

WSL logs: https://aka.ms/AAbd8pm

Expected behavior

The stat call should succeed in 32-bit processes when provided with a valid Windows filesystem path.

Actual behavior

The stat call fails in a 32-bit process when provided with a valid Windows filesystem path.

@doxxx
Copy link
Author

doxxx commented Mar 1, 2021

The specific situation that this occurred in was compiling GoogleTest unit tests for code used in a 32-bit embedded system. To replicate the 32-bit environment of the embedded system, the unit tests were compiled with -m32. When running the tests with the --gtest_output=xml:testresults.xml option, it was failing with an "Unable to open file" error for the results file, which happened to be a Windows filesystem path.

@0xbadfca11
Copy link

It's not a WSL issue as it happens on native Linux with XFS too.
Should compile with #define _FILE_OFFSET_BITS 64.

http://www.mjr19.org.uk/sw/inodes64.html

@doxxx
Copy link
Author

doxxx commented Mar 2, 2021

I can confirm that adding the above compiler define fixes the problem in both the little test app above and in my GoogleTest scenario.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants