Mailing List Archive

[Bug 3584] Segfault when built with optimisations on macOS 13 (x86_64) with Xcode 14.3
https://bugzilla.mindrot.org/show_bug.cgi?id=3584

Damien Miller <djm@mindrot.org> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |djm@mindrot.org

--- Comment #1 from Damien Miller <djm@mindrot.org> ---
This really looks like a bad bug in XCode/clang. It might be caused by
an incompatibility between the options we set in configure.ac and -Os,
which admittedly doesn't get a lot of test coverage.

Could you try rebuilding after "configure --without-hardening" and
seeing if that helps?

--
You are receiving this mail because:
You are watching someone on the CC list of the bug.
You are watching the assignee of the bug.
_______________________________________________
openssh-bugs mailing list
openssh-bugs@mindrot.org
https://lists.mindrot.org/mailman/listinfo/openssh-bugs
[Bug 3584] Segfault when built with optimisations on macOS 13 (x86_64) with Xcode 14.3 [ In reply to ]
https://bugzilla.mindrot.org/show_bug.cgi?id=3584

--- Comment #2 from Carlo Cabrera <carlo.antonio.cabrera@gmail.com> ---
Yes, at Homebrew, we've also come to the conclusion that this is a
compiler bug (likely in the backend). I'll try to find the time to
report this to Apple.

Passing `--without-hardening` to `configure` also makes the segfault go
away, even if we pass `-Os` to the compiler.

Do you have a recommendation on which workaround is better to adopt?

--
You are receiving this mail because:
You are watching the assignee of the bug.
You are watching someone on the CC list of the bug.
_______________________________________________
openssh-bugs mailing list
openssh-bugs@mindrot.org
https://lists.mindrot.org/mailman/listinfo/openssh-bugs
[Bug 3584] Segfault when built with optimisations on macOS 13 (x86_64) with Xcode 14.3 [ In reply to ]
https://bugzilla.mindrot.org/show_bug.cgi?id=3584

Darren Tucker <dtucker@dtucker.net> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |dtucker@dtucker.net

--- Comment #3 from Darren Tucker <dtucker@dtucker.net> ---
(In reply to Carlo Cabrera from comment #2)
> Do you have a recommendation on which workaround is better to adopt?

IMO you'd be better off with the compiler hardening flags rather than
-Os. Things like -ftrapv could mitigate what would otherwise be a
vulnerability.

If you want to investigate further, you could enumerate the flags added
by --with-hardening (which will depend on what the compiler supports,
you could diff Makefile generated with and without) and add them to
CFLAGS one at a time along with -Os and see if you can narrow down
which of them triggers the problem.

(I tried installing xcode 14.3 to reproduce but my test mac doesn't
support a new enough OSX version to do that.)

--
You are receiving this mail because:
You are watching someone on the CC list of the bug.
You are watching the assignee of the bug.
_______________________________________________
openssh-bugs mailing list
openssh-bugs@mindrot.org
https://lists.mindrot.org/mailman/listinfo/openssh-bugs
[Bug 3584] Segfault when built with optimisations on macOS 13 (x86_64) with Xcode 14.3 [ In reply to ]
https://bugzilla.mindrot.org/show_bug.cgi?id=3584

--- Comment #4 from Carlo Cabrera <carlo.antonio.cabrera@gmail.com> ---
> IMO you'd be better off with the compiler hardening flags rather
> than -Os. Things like -ftrapv could mitigate what would otherwise
> be a vulnerability.

Ok, sounds good. We (Homebrew) recently had to rebuild our OpenSSH
package to use OpenSSL 3 and shipped it without `-O` flags on macOS
13-x86_64, so we're not going to change that for now.

> If you want to investigate further, you could enumerate the flags
> added by --with-hardening (which will depend on what the compiler
> supports, you could diff Makefile generated with and without) and
> add them to CFLAGS one at a time along with -Os and see if you can
> narrow down which of them triggers the problem.

Thanks for the tip. I'll also try to find the time to do this.

> (I tried installing xcode 14.3 to reproduce but my test mac doesn't
> support a new enough OSX version to do that.)

GitHub provides free access to macOS runners for public repositories,
and these have various versions of Xcode installed. This is what I'll
probably end up using to investigate this problem further, but you
might also be inclined to do the same.

--
You are receiving this mail because:
You are watching the assignee of the bug.
You are watching someone on the CC list of the bug.
_______________________________________________
openssh-bugs mailing list
openssh-bugs@mindrot.org
https://lists.mindrot.org/mailman/listinfo/openssh-bugs
[Bug 3584] Segfault when built with optimisations on macOS 13 (x86_64) with Xcode 14.3 [ In reply to ]
https://bugzilla.mindrot.org/show_bug.cgi?id=3584

--- Comment #5 from Damien Miller <djm@mindrot.org> ---
Darren already answered your question but fwiw I didn't suggest
--without-hardening as a workaround, but to determine whether the
compiler bug is with -Os alone or when combined with other flags.

--
You are receiving this mail because:
You are watching the assignee of the bug.
You are watching someone on the CC list of the bug.
_______________________________________________
openssh-bugs mailing list
openssh-bugs@mindrot.org
https://lists.mindrot.org/mailman/listinfo/openssh-bugs
[Bug 3584] Segfault when built with optimisations on macOS 13 (x86_64) with Xcode 14.3 [ In reply to ]
https://bugzilla.mindrot.org/show_bug.cgi?id=3584

--- Comment #6 from Darren Tucker <dtucker@dtucker.net> ---
(In reply to Carlo Cabrera from comment #4)
[...]
> GitHub provides free access to macOS runners for public
> repositories, and these have various versions of Xcode installed.

An interesting idea. We already use these in our CI tests, eg
https://github.com/openssh/openssh-portable/actions/runs/5351378114
however we don't currently use anything except the default compilers.
How do you select specific xcode versions?

They're a bit inconvenient to interact with for debugging (short of
hacks) but
better than nothing.

--
You are receiving this mail because:
You are watching someone on the CC list of the bug.
You are watching the assignee of the bug.
_______________________________________________
openssh-bugs mailing list
openssh-bugs@mindrot.org
https://lists.mindrot.org/mailman/listinfo/openssh-bugs
[Bug 3584] Segfault when built with optimisations on macOS 13 (x86_64) with Xcode 14.3 [ In reply to ]
https://bugzilla.mindrot.org/show_bug.cgi?id=3584

--- Comment #7 from Carlo Cabrera <carlo.antonio.cabrera@gmail.com> ---
> How do you select specific xcode versions?

You can use `xcode-select --switch /path/to/Xcode.app`. For example, to
use Xcode 14.3.1 on a GitHub macos-13 runner [1], do
```
sudo xcode-select --switch Applications/Xcode_14.3.1.app
```
You can also use `-s` instead of `--switch`.

[1]
https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md#xcode

--
You are receiving this mail because:
You are watching someone on the CC list of the bug.
You are watching the assignee of the bug.
_______________________________________________
openssh-bugs mailing list
openssh-bugs@mindrot.org
https://lists.mindrot.org/mailman/listinfo/openssh-bugs
[Bug 3584] Segfault when built with optimisations on macOS 13 (x86_64) with Xcode 14.3 [ In reply to ]
https://bugzilla.mindrot.org/show_bug.cgi?id=3584

Michael Cho <cho-m@tuta.io> changed:

What |Removed |Added
----------------------------------------------------------------------------
CC| |cho-m@tuta.io

--- Comment #8 from Michael Cho <cho-m@tuta.io> ---
Changing optimization only masked issue during build but resulting
binaries caused segfaults and other problems for Homebrew users.

Based on my analysis, the issue appears to be that Xcode 14.3 (Apple
Clang 14.0.3) is based on LLVM 15 and thus we hit the LLVM bug
mentioned in configure.ac (ref:
https://github.com/llvm/llvm-project/issues/59242,
https://reviews.llvm.org/D139679)

Version info is a bit annoying with Apple Clang since they don't align
with LLVM version numbers. Also, the text is different so the
configure.ac logic doesn't work
```
? clang -v 2>&1 | head -1
Apple clang version 14.0.3 (clang-1403.0.22.14.1)

? clang -v 2>&1 | awk '/clang version /{print $3}'
version
```

In Homebrew, I added a temporary workaround in
https://github.com/Homebrew/homebrew-core/pull/135373 but would be nice
to improve configure.ac logic.

Issue should go away with Xcode 15 release as Apple Clang 15.0.0 is
based on LLVM 16.

--
You are receiving this mail because:
You are watching someone on the CC list of the bug.
You are watching the assignee of the bug.
_______________________________________________
openssh-bugs mailing list
openssh-bugs@mindrot.org
https://lists.mindrot.org/mailman/listinfo/openssh-bugs
[Bug 3584] Segfault when built with optimisations on macOS 13 (x86_64) with Xcode 14.3 [ In reply to ]
https://bugzilla.mindrot.org/show_bug.cgi?id=3584

--- Comment #9 from Carlo Cabrera <carlo.antonio.cabrera@gmail.com> ---
Yes, so it looks like `configure.ac` already knows to avoid
`-fzero-call-used-regs=all` when compiling with `clang-15`, except that
Apple clang uses a misleading version scheme.

Wikipedia is usually a pretty reliable reference for the corresponding
LLVM version given the version string produced by `clang --version`,
though:
https://en.wikipedia.org/wiki/Xcode#Xcode_11.0_-_14.x_(since_SwiftUI_framework)_2

--
You are receiving this mail because:
You are watching someone on the CC list of the bug.
You are watching the assignee of the bug.
_______________________________________________
openssh-bugs mailing list
openssh-bugs@mindrot.org
https://lists.mindrot.org/mailman/listinfo/openssh-bugs