mainAutoconf - Support: sr #110740, AC_PROG_MKDIR_P has incorrect...

 
 

sr #110740: AC_PROG_MKDIR_P has incorrect result on NetBSD

Submitter:  Thomas Klausner <tk>
Submitted:  Tue 11 Oct 2022 03:19:07 PM UTC
   
 
Priority:  * 5 - Unprioritized Severity:  3 - Normal
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Closed
Operating System:  *BSD
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Thu 13 Oct 2022 09:44:07 AM UTC, comment #8: 

Thanks, Paul!

Thomas Klausner <tk>
Wed 12 Oct 2022 07:16:46 PM UTC, comment #7: 

comment #6:

> Assuming postgresql wants to work with current Autoconf, it can put in something like "case $MKDIR_P in /*) ;; /) MKDIR_P='mkdir -p';; esac" ...


Oops, I see that Savannah botched the rendering of that shell code. Here's what it is supposed to look like:


case $MKDIR_P in /*) ;; */*) MKDIR_P='mkdir -p';; esac


Paul Eggert <eggert>
Group administrator
Wed 12 Oct 2022 07:13:54 PM UTC, comment #6: 

Thanks for mentioning the postgresql situation. I went back and looked back at autoconf, and it seems to me that all things considered,nowadays the cure of using a relative install-sh path is worse than the disease of ancient mkdirs that don't work properly. If so, it's better now for AC_PROG_MKDIR_P to fall back on plain mkdir -p than on a relative path to install-sh, so I installed a patch to do that. Only the last four lines of that patch affect functionality; everything else is documentation.

Assuming postgresql wants to work with current Autoconf, it can put in something like "case $MKDIR_P in /*) ;; /) MKDIR_P='mkdir -p';; esac" into the appropriate place in configure.ac. This should work around the problem now, and should be a no-op in later Autoconf versions.

Paul Eggert <eggert>
Group administrator
Tue 11 Oct 2022 11:08:11 PM UTC, comment #5: 

Actually this bug led to uncovering another, difficult-to-find bug, that is somewhere between postgis and postgresql's pgxs makefiles.   It's complicated, but the essence is that postgresql does configure tests and then generates make fragments for extensions.  It tries to adapt relative paths (such as this one) but somehow, despite postgis using autoconf and having config/install-sh in the same place, the path to pgxs's copy is lost.   This caused mysterious, hard to figure out problems.

I see the point that install-sh works and thus this is minor, but wrongly rejecting valid mkdir leads to exercising code paths that are not debugged on systems where mkdir is accepted.

After asking about this on the relevant NetBSD technical list, the code was explained: mkdir is called and then stat, so if something else did mkdir, no error is thrown.  This was true as of NetBSD 8, the oldest non-EOL version, so it's fair to accept base system mkdir always.

Greg Troxel <gdt>
Tue 11 Oct 2022 05:29:30 PM UTC, comment #4: 

For reference, this particular issue caused fallout because postgresql's build system used the resulting MKDIR variable, more details here:

https://mail-index.netbsd.org/tech-pkg/2022/10/09/msg026848.html

Thomas Klausner <tk>
Tue 11 Oct 2022 05:21:31 PM UTC, comment #3: 

This is not a serious bug, as "make install" is supposed to fall back on install-sh in this case, and install-sh should do the right thing on platforms like NetBSD where mkdir works correctly. So the bug is merely that installations are a bit slower on NetBSD.

If someone could verify that the relevant OSes have been fixed, and that the older race-buggy versions of mkdir have been end-of-lifed by NetBSD, etc., and could write the Autoconf patches accordingly, that would be nice. It would likely require pawing through decades-old Git logs or whatever.

Marking the bug as minor.

Paul Eggert <eggert>
Group administrator
Tue 11 Oct 2022 05:04:22 PM UTC, comment #2: 

I agree that this is difficult to test for.

In a recent discussion on NetBSD mailing lists people wondered what operating systems still have raceful mkdir(1) implementations. Perhaps the test should use a list of operating systems that are known to have "bad" mkdir(1); or a list of known-good operating systems if noone knows which ones are "bad".

Thomas Klausner <tk>
Tue 11 Oct 2022 04:42:15 PM UTC, comment #1: 

Version checks are always fragile, but writing a functional probe for properties related to race conditions can be extremely difficult.  Do you have any ideas for how we should go about it?

Zack Weinberg <zackw>
Group administrator
Tue 11 Oct 2022 03:19:07 PM UTC, original submission:  

The AC_PROG_MKDIR_P() macro is supposed to check for a race-free mkdir(1). NetBSD's is race-free but is not detected as such.

Basic test case is attached. When configure is run, I get:

checking for a race-free mkdir -p... ./install-sh -c -d

Looking at the generated configure code, the test seems to consist of running 'mkdir --version' and comparing the result to a few known-good values. This fails on NetBSD since NetBSD's mkdir does not support --version.

Looking at the FreeBSD and OpenBSD and macOS man pages, --version is not supported either, so this will fail in the same way there.

Thomas Klausner <tk>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #53836:  configure.ac added by tk (40B - application/octet-stream)
file #53835:  configure.ac added by tk (40B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by gdt (Posted a comment)
  • -email is unavailable- added by eggert (Posted a comment)
  • -email is unavailable- added by zackw (Posted a comment)
  • -email is unavailable- added by tk (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-10-12 eggert Priority3 - Release N+1 5 - Unprioritized
        Severity2 - Minor 3 - Normal
        Open/ClosedOpen Closed
    2022-10-11 eggert Priority5 - Unprioritized 3 - Release N+1
    2022-10-11 eggert Severity3 - Normal 2 - Minor
    2022-10-11 tk Attached File- Added configure.ac, #53835
        Attached File- Added configure.ac, #53836

    Back to the top

    Powered by Savane 3.13-d3ae.
    Corresponding source code