Opened 11 years ago

Last modified 8 years ago

#6659 reopened Bugs

Filesystem compilation broken on Solaris 9 and 10

Reported by: Vasily Sukhanov <basil@…> Owned by: Beman Dawes
Milestone: To Be Determined Component: filesystem
Version: Boost 1.49.0 Severity: Regression
Keywords: compilation Cc: duncanphilipnorman@…, chrmhoffmann@…

Description

Output message:

libs/filesystem/v3/src/operations.cpp: In function âvoid boost::filesystem3::detail::permissions(const boost::filesystem3::path&, boost::filesystem3::perms, boost::system::error_code*)â: libs/filesystem/v3/src/operations.cpp:1391:11: error: â::fchmodatâ has not been declared

This is regression, 1.48 compiles well. I reproduced on both sparc and x86 platforms.

Attachments (3)

boost-1.49.0-dont_use_fchmodat.patch (1.0 KB ) - added by Duncan Exon Smith <duncanphilipnorman@…> 11 years ago.
Patch to remove unnecessary use of poorly supported fchmodat().
test-fchmodat.cpp (727 bytes ) - added by Duncan Exon Smith <duncanphilipnorman@…> 10 years ago.
Test program to demonstrate that Linux does not support AT_SYMLINK_NOFOLLOW.
linux-no_fchmod_at-r79468.patch (1.3 KB ) - added by Duncan Exon Smith <duncanphilipnorman@…> 10 years ago.
Patch to stop using fchmodat() on Linux, with an explanation in the comments.

Download all attachments as: .zip

Change History (18)

comment:1 by Beman Dawes, 11 years ago

Status: newassigned

Here is the code:

Mac OS X Lion and some other platforms don't support fchmodat()

# if defined(AT_FDCWD) && defined(AT_SYMLINK_NOFOLLOW) \

&& (!defined(SUNPRO_CC)
SUNPRO_CC > 0x5100)

if (::fchmodat(AT_FDCWD, p.c_str(), mode_cast(prms),

!(prms & symlink_perms) ? 0 : AT_SYMLINK_NOFOLLOW))

# else fallback if fchmodat() not supported

if (::chmod(p.c_str(), mode_cast(prms)))

# endif

I'm guessing the SUNPRO_CC code is wrong. If you could submit a tested patch, I'd appreciate it.

Thanks,

--Beman

comment:2 by Vasily Sukhanov <basil@…>, 11 years ago

SUNPRO_CC has no relation to my case. I had to write that I am using GCC 4.5.3. I didn't find this function in Solaris headers. Documentation (http://docs.oracle.com/cd/E19963-01/html/821-1463/chmod-2.html) says fchmodat is present in Solaris 11.

in reply to:  1 comment:3 by Duncan Exon Smith <duncanphilipnorman@…>, 11 years ago

Cc: duncanphilipnorman@… added

Just a note that I ran into this on Linux, albeit in a strange circumstance.

Replying to bemandawes:

Here is the code:

Beman, I think you broke the Trac renderer (it's adding funny italics because of the // comments). Perhaps you'd be willing to edit your comment:

comment:4 by Duncan Exon Smith <duncanphilipnorman@…>, 11 years ago

Another note: AT_SYMLINK_NOFOLLOW does not appear to be supported even in Linux.

by Duncan Exon Smith <duncanphilipnorman@…>, 11 years ago

Attachment: boost-1.49.0-dont_use_fchmodat.patch added

Patch to remove unnecessary use of poorly supported fchmodat().

in reply to:  4 comment:5 by Duncan Exon Smith <duncanphilipnorman@…>, 11 years ago

Replying to Duncan Exon Smith <duncanphilipnorman@…>:

Another note: AT_SYMLINK_NOFOLLOW does not appear to be supported even in Linux.

I've added attachment:boost-1.49.0-dont_use_fchmodat.patch as one way of fixing these problems (as well as the original problem on Solaris), although I admit it may be heavy-handed.

comment:6 by Vasily Sukhanov <basil@…>, 10 years ago

Why wasn't this patch integrated into boost 1.50?

in reply to:  6 comment:7 by Duncan Exon Smith <duncanphilipnorman@…>, 10 years ago

Replying to Vasily Sukhanov <basil@…>:

Why wasn't this patch integrated into boost 1.50?

I don't know. Beman?

comment:8 by anonymous, 10 years ago

In the Solaris case, testing the value of SUNPRO_CC won't tell us if fchmodat is supported. For that we need to test whether the system is Solaris 11 or not. The following will test for Solaris 11 if you are using Solaris Studio compilers

defined(__SUNPRO_CC) && defined(__SunOS_5_11)

comment:9 by Vasily Sukhanov <basil@…>, 10 years ago

This is a narrow case. I'm using gcc.

by Duncan Exon Smith <duncanphilipnorman@…>, 10 years ago

Attachment: test-fchmodat.cpp added

Test program to demonstrate that Linux does not support AT_SYMLINK_NOFOLLOW.

comment:10 by chrmhoffmann@…, 10 years ago

Cc: chrmhoffmann@… added

comment:11 by Beman Dawes, 10 years ago

Test_fchmodat.cpp was quite helpful. It runs without asserts a fresh install of Ubuntu 12.04.

The problem with the patch is that, as you said, it is too heavy handed. It looses too much information, both in comments and in code.

On Linux, I'd prefer to try fchmodat with AT_SYMLINK_NOFOLLOW and then if it fails with ENOTSUP, try again with 0 instead of AT_SYMLINK_NOFOLLOW. That way the code will work correctly if Linux ever fixes AT_SYMLINK_NOFOLLOW. A comment is needed to explain why the code is written that way, too.

I'd prefer you rework the patch, test it, and resubmit.

Thanks,

--Beman

in reply to:  11 comment:12 by Duncan Exon Smith <duncanphilipnorman@…>, 10 years ago

Replying to bemandawes:

I'd prefer you rework the patch, test it, and resubmit.

I've put together another patch that avoids fchmodat() on Linux (but only Linux, this time). Let me argue why:

This version of the patch (attachment:linux-no_fchmod_at-r79468.patch) applies cleanly to the trunk at r79568.

Finally, I don't have access to a Solaris system for testing.

by Duncan Exon Smith <duncanphilipnorman@…>, 10 years ago

Attachment: linux-no_fchmod_at-r79468.patch added

Patch to stop using fchmodat() on Linux, with an explanation in the comments.

comment:13 by Beman Dawes, 10 years ago

Resolution: fixed
Status: assignedclosed

(In [79484]) Fix #6659 and #7051, fchmodat supported only on Solaris 11. Disable fchmodat for both Sun and GCC compilers regardless of OS version; a runtime check is too much trouble.

comment:14 by anonymous, 10 years ago

Hi,

Shouldn't this be handled in the config.hpp rather than with ifdefs in the cpp code itself?

Otherwise thanks for looking into this.

Rgds, Chris

comment:15 by szatmari.zs@…, 8 years ago

Resolution: fixed
Status: closedreopened

Hi!

This causes problems again. If compiled on a Mac with a target sdk of OS X 10.10 (Yosemite), but -mmacosx-version-min=10.7 (or anything before 10.10), it compiles and links successfully, but it will crash when deployed on older os, but only if it hits this function, so it might appear to be quite hectic and hard to diagnose if deployed on the end user's machine, therefore this is a severe problem. I am sure mmacosx-version-min defines some macros, but I wouldn't bother with it, really, just add an another fallback condition for chmod if:

defined(APPLE)

so operations.cpp:1418 becomes:

# if defined(AT_FDCWD) && defined(AT_SYMLINK_NOFOLLOW) \

&& !(defined(SUNPRO_CC) && !(defined(linux)
defined(sun) defined(sun)) \
defined(linux) defined(linux)) \

&& !(defined(APPLE))

Note: See TracTickets for help on using tickets.