Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 632500 - macOS 10.13/High Sierra intentionally crashes process when *printf() format-string in writable memory contains '%n' formatter
Summary: macOS 10.13/High Sierra intentionally crashes process when *printf() format-s...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo/Alt
Classification: Unclassified
Component: Prefix Support (show other bugs)
Hardware: AMD64 OS X
: Normal critical with 1 vote (vote)
Assignee: Gentoo Prefix
URL: https://github.com/Homebrew/homebrew-...
Whiteboard:
Keywords:
: 634762 (view as bug list)
Depends on: 633980 637252
Blocks:
  Show dependency tree
 
Reported: 2017-09-30 11:31 UTC by Stuart Shelton
Modified: 2018-01-04 09:49 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stuart Shelton 2017-09-30 11:31:18 UTC
Problem discussed at:
http://lists.gnu.org/archive/html/bug-gnulib/2017-07/msg00056.html
http://lists.gnu.org/archive/html/bug-gnulib/2017-07/msg00058.html

... and:
https://github.com/Homebrew/homebrew-core/issues/14418

The MacOS 10.13 profile needs a whole load of additional package masks to prevent the installation of affected ebuilds, and core packages may need to be Gentoo-patched now until upstream catches up :(

Symptom:

>  $ ls /var/empty/
>  $ ls "doesn't exist"
>  ls: Illegal instruction: 4

... so sys-apps/coreutils-8.26 'ls' appears to use '%n', but only when reporting failures.
Comment 1 Stuart Shelton 2017-09-30 11:54:30 UTC
... unless sys-devel/m4 can be patched with https://raw.githubusercontent.com/macports/macports-ports/edf0ee1e2cf/devel/m4/files/secure_snprintf.patch and that's enough to fix all instances... how many packages use their own bundled versions of m4, or are affected by the same problem elsewhere.

This would be much easier to fix if there was a specific compiler option which generated an error on this usage, rather than relying on runtime crashes :(
Comment 2 Stuart Shelton 2017-09-30 12:34:48 UTC
Actually, this is a more useful resource:

https://github.com/Homebrew/homebrew-core/pull/15129
Comment 3 Stuart Shelton 2017-10-02 13:37:12 UTC
So I think I've adequately solved the vasnprintf() case automatically, pending upstream changes, as per https://github.com/srcshelton/gentoo-ebuilds/blob/master/README.md#fixes-for-compiling-prefix-packages-on-macos-1013-high-sierra-and-later

As noted, what other cases there may be is unclear...
Comment 4 abcdsoec 2017-10-30 16:23:37 UTC
This problem also cause error when compiling bison at stage 2 of bootstrap on macOS.

http://lists.gnu.org/archive/html/bug-bison/2017-09/msg00001.html
Comment 5 Fabian Groffen gentoo-dev 2017-11-12 12:24:01 UTC
m4 fix pushed
flex failure is caused by m4
bison fix pushed
Comment 6 Fabian Groffen gentoo-dev 2017-11-12 12:56:57 UTC
*** Bug 634762 has been marked as a duplicate of this bug. ***
Comment 7 Fabian Groffen gentoo-dev 2017-11-12 18:12:08 UTC
coreutils bumped (removed need for a fix)
curl fix pending
Comment 8 Fabian Groffen gentoo-dev 2017-11-13 18:33:40 UTC
bootstrapping works, glib fails blocking emerge -e world completion.
Comment 9 Fabian Groffen gentoo-dev 2017-11-14 08:52:41 UTC
glib issue is a mismatch between clang and system headers, need to upgrade clang :(
Comment 10 Michael Weiser 2017-12-28 10:59:43 UTC
%n problem is also in portage-utils-0.64-r1 and causes an error at the end of emaint sync. Goes away when patching autotools/gnulib/lib/vasnprintf.c with bison-3.0.4-darwin17-printf-n.patch out of the bison ebuild. Updating gnulib with autogen.sh isn't straight-forward. Perhaps upstream can make a new release?
Comment 11 Fabian Groffen gentoo-dev 2017-12-28 11:04:26 UTC
I was already working on that (I recently bumped gnulib release), but I don't want to update all my machines to HS until I know I can make it work, so I don't have access all the time to it :)
Comment 12 Fabian Groffen gentoo-dev 2017-12-29 12:55:37 UTC
portage-utils-0.65 compiles/runs on high-sierra
Comment 13 Fabian Groffen gentoo-dev 2018-01-03 14:37:39 UTC
clang-5.0.1 is now in the tree (thanks to Michael Weiser) I will keyword it shortly.  This version is able to compile glib on High Sierra.
Comment 14 Larry the Git Cow gentoo-dev 2018-01-04 09:46:19 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=bd802a20f3c8d250fd85ed66272df93583edde2a

commit bd802a20f3c8d250fd85ed66272df93583edde2a
Author:     Fabian Groffen <grobian@gentoo.org>
AuthorDate: 2018-01-04 09:46:00 +0000
Commit:     Fabian Groffen <grobian@gentoo.org>
CommitDate: 2018-01-04 09:46:00 +0000

    scripts/bootstrap-prefix: update snapshots
    
    Bug: https://bugs.gentoo.org/642656
    Bug: https://bugs.gentoo.org/618396
    Bug: https://bugs.gentoo.org/632500
    Bug: https://bugs.gentoo.org/638816

 scripts/bootstrap-prefix.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)}