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

Using boost::filesystem in Boost 1.75.0 onwards fails trying to call syscall(__NR_statx, ...) #6994

Closed
1 of 2 tasks
fun4jimmy opened this issue May 26, 2021 · 3 comments
Closed
1 of 2 tasks
Labels

Comments

@fun4jimmy
Copy link

fun4jimmy commented May 26, 2021

Windows Build Number

Microsoft Windows [Version 10.0.19042.985]

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

Linux version 4.4.0-19041-Microsoft (Microsoft@Microsoft.com) (gcc version 5.4.0 (GCC) ) #488-Microsoft Mon Sep 01 13:43:00 PST 2020

Distro Version

Ubuntu 18.04

Other Software

gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Boost 1.75.0

Repro Steps

Download, extract and build Boost 1.75.0:

wget https://boostorg.jfrog.io/artifactory/main/release/1.75.0/source/boost_1_75_0.tar.gz
tar -zxf boost_1_75_0.tar.gz
cd boost_1_75_0
./bootstrap.sh --prefix=installed
# This call to b2 will perform some configuration checks including the statx syscall check which will pass successfully
./b2 install variant=debug --without-python --without-iostreams --without-mpi

Write a simple program status_test.cpp that uses a boost::filesystem call that relies on statx:

#include <boost/filesystem/operations.hpp>

int main(int argc, char** argv)
{
  boost::filesystem::path FilePath("/etc/fstab");
  auto Status = boost::filesystem::status(FilePath);
  return 0;
}

Compile and run the program (assumes status_test.cpp is in the same directory as the build of boost):

g++ status_test.cpp -g -Iinstalled/include -Linstalled/lib -lboost_filesystem
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD/installed/lib
./a.out

Expected Behavior

The call to boost::filesystem::status in the sample application was successful and the program returns 0 with no errors.

Actual Behavior

The actual output of the program is a thrown exception with a misleading error message:

terminate called after throwing an instance of 'boost::filesystem::filesystem_error'
  what():  boost::filesystem::status: Function not implemented: "/etc/fstab"
Aborted (core dumped)

If you step into the call to boost::filesystem::status you will see that the program fails when trying to call the boost::filesystem statx wrapper (boost_1_75_0\libs\filesystem\src\operations.cpp(367)):

inline int statx(int dirfd, const char* path, int flags, unsigned int mask, struct ::statx* stx) BOOST_NOEXCEPT
{
  return ::syscall(__NR_statx, dirfd, path, flags, mask, stx);
}

I think the problem is that the WSL kernel headers indicate that syscall(__NR_statx, ...) will work but the function is not actually implemented.

Diagnostic Logs

No response

@fun4jimmy
Copy link
Author

I think this may be a similar issue found by nodejs nodejs/node#30860.
This WSL issue may also be related #3023.

@fun4jimmy
Copy link
Author

It looks like the authors of boost::filesystem are adding a workaround to manually disable statx support if necessary (https://github.com/boostorg/filesystem/blob/develop/build/Jamfile.v2#L66) but that is not available in any released version of boost (1.75.0 or 1.76.0) yet.
Also, it would be preferable to be able to use the same boost binary on WSL and native Ubuntu distributions with performance benefits from using statx.

Copy link
Contributor

This issue has been automatically closed since it has not had any activity for the past year. If you're still experiencing this issue please re-file this as a new issue or feature request.

Thank you!

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

No branches or pull requests

2 participants