Skip to content

fixing openssh segmentation fault for darwin Intel-based platforms#40044

Merged
bernhardkaindl merged 3 commits intospack:developfrom
thiagogenez:bugfix/openssh
Sep 21, 2023
Merged

fixing openssh segmentation fault for darwin Intel-based platforms#40044
bernhardkaindl merged 3 commits intospack:developfrom
thiagogenez:bugfix/openssh

Conversation

@thiagogenez
Copy link
Copy Markdown

This PR addresses two topics when building openssh on darwin-based platforms

Changes

  • First, a segment fault issue below
/bin/bash: line 1: 44705 Segmentation fault: 11  ./ssh-keygen -A
make: *** [host-key] Error 139
==> Error: ProcessError: Command exited with status 2:
    'make' '-j1' 'install'

1 error found in build log:
     2363    /usr/local/bin/ginstall -c -m 644 sftp-server.8.out /usr/local/Cellar/spack/0.20.1/opt/spack/darwin-ventura-cannonlake/apple-clang-14.0.3/openss
             h-9.3p1-akitf76dwusw6vv7avi3zx5s64tlffpg/share/man/man8/sftp-server.8
     2364    /usr/local/bin/ginstall -c -m 644 ssh-keysign.8.out /usr/local/Cellar/spack/0.20.1/opt/spack/darwin-ventura-cannonlake/apple-clang-14.0.3/openss
             h-9.3p1-akitf76dwusw6vv7avi3zx5s64tlffpg/share/man/man8/ssh-keysign.8
     2365    /usr/local/bin/ginstall -c -m 644 ssh-pkcs11-helper.8.out /usr/local/Cellar/spack/0.20.1/opt/spack/darwin-ventura-cannonlake/apple-clang-14.0.3/
             openssh-9.3p1-akitf76dwusw6vv7avi3zx5s64tlffpg/share/man/man8/ssh-pkcs11-helper.8
     2366    /usr/local/bin/ginstall -c -m 644 ssh-sk-helper.8.out /usr/local/Cellar/spack/0.20.1/opt/spack/darwin-ventura-cannonlake/apple-clang-14.0.3/open
             ssh-9.3p1-akitf76dwusw6vv7avi3zx5s64tlffpg/share/man/man8/ssh-sk-helper.8
     2367    /usr/local/bin/gmkdir -p /usr/local/Cellar/spack/0.20.1/opt/spack/darwin-ventura-cannonlake/apple-clang-14.0.3/openssh-9.3p1-akitf76dwusw6vv7avi
             3zx5s64tlffpg/etc
     2368    /bin/bash: line 1: 44705 Segmentation fault: 11  ./ssh-keygen -A
  >> 2369    make: *** [host-key] Error 139

is solved by adding the patch

if self.spec.target.family == "x86_64" and self.spec.platform == "darwin":
    filter_file(r"-fzero-call-used-regs=all", "-fzero-call-used-regs=used", "configure")
  • Secondly, this PR adds two patches are applied by Apple
    # https://github.com/Homebrew/homebrew-core/blob/7aabdeb30506be9b01708793ae553502c115dfc8/Formula/o/openssh.rb#L40-L45
    patch(
        "https://raw.githubusercontent.com/Homebrew/patches/1860b0a745f1fe726900974845d1b0dd3c3398d6/openssh/patch-sandbox-darwin.c-apple-sandbox-named-external.diff",
        sha256="d886b98f99fd27e3157b02b5b57f3fb49f43fd33806195970d4567f12be66e71",
        when="platform=darwin",
    )

    # https://github.com/Homebrew/homebrew-core/blob/7aabdeb30506be9b01708793ae553502c115dfc8/Formula/o/openssh.rb#L48-L52C6
    patch(
        "https://raw.githubusercontent.com/Homebrew/patches/d8b2d8c2612fd251ac6de17bf0cc5174c3aab94c/openssh/patch-sshd.c-apple-sandbox-named-external.diff",
        sha256="3505c58bf1e584c8af92d916fe5f3f1899a6b15cc64a00ddece1dc0874b2f78f",
        when="platform=darwin",
    )

which are activated by

        if self.spec.platform == "darwin":
            env.append_flags("CPPFLAGS", "-D__APPLE_SANDBOX_NAMED_EXTERNAL__")

Sources

All the patches were taken from Homebrew OpenSSH formula

Testing

With this PR, openssh have been successfully installed

==> openssh: Successfully installed openssh-9.3p1-7kvqjhq4v42plmq3k25hpk23bsr7dux5
  Stage: 0.39s.  Autoreconf: 0.00s.  Configure: 2m 26.75s.  Build: 30.04s.  Install: 1.93s.  Post-install: 0.23s.  Total: 2m 59.88s
[+] /usr/local/Cellar/spack/0.20.1/opt/spack/darwin-ventura-cannonlake/apple-clang-14.0.3/openssh-9.3p1-7kvqjhq4v42plmq3k25hpk23bsr7dux5

System

sw_vers                                                                                                                                                 ─╯
ProductName:		macOS
ProductVersion:		13.5.2
BuildVersion:		22G91

@thiagogenez thiagogenez changed the title fixing Segmentation fault for darwin Intel-based platforms fixing openssh segmentation fault for darwin Intel-based platforms Sep 15, 2023
@bernhardkaindl bernhardkaindl merged commit 43ed8a1 into spack:develop Sep 21, 2023
@thiagogenez thiagogenez deleted the bugfix/openssh branch September 25, 2023 10:39
RikkiButler20 pushed a commit to RikkiButler20/spack that referenced this pull request Sep 25, 2023
AdhocMan pushed a commit to AdhocMan/spack that referenced this pull request Oct 10, 2023
mtaillefumier pushed a commit to mtaillefumier/spack that referenced this pull request Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants