herd-community icon indicating copy to clipboard operation
herd-community copied to clipboard

[Bug]: Connection to SFTP server via phpseclib causes segmentation fault

Open buddhaCode opened this issue 1 year ago • 2 comments

Platform

macOS

Operating system version

macOS Sonoma 14.6.1 (23G93)

System architecture

Intel (x86)

Herd Version

1.11.2 (Build: 35)

PHP Version

No response

Bug description

Hello guys, I'm trying to connect to a SFTP server via the Laravel storage facade. The storage facade uses Flysystem, which itself uses the phpseclib package. I use the following versions:

laravel/framework 11.27.2 league/flysystem-sftp-v3 3.29.0 phpseclib/phpseclib 3.0.42

When I am trying to connect to the server I get a segmentation fault.

I have tested PHP 8.2.25, PHP 8.3.13 and 8.4.0RC3. On the CLI a get the segmentation fault and with FPM I get a 502 Bad Gateway.

I also tested PHP 8.3.12 (cli) from Brew. With the Brew built everything works as expected.

Steps to reproduce

$sftp = new \phpseclib3\Net\SFTP('host');
$sftp->login('user', 'pass');

Relevant log output

> php artisan sftp
zsh: segmentation fault

buddhaCode avatar Oct 30 '24 11:10 buddhaCode

I just asked a co-worker to run my code with the apple silicon build. The silicon build has no problems with the phpseclib library.

Versions:

PHP 8.3 (8.3.12) Herd 1.11.2 Sonoma 14.5

buddhaCode avatar Nov 04 '24 12:11 buddhaCode

The latest static-php-cli macOS x86_64 build looks good to me though. II'm not sure if there are any issues with Herd yet, need @mpociot to confirm this.

I don't have an Intel Mac, but if there is a direct link to the PHP binary that Herd uses, I could download one for testing with rosetta.

crazywhalecc avatar Jul 23 '25 05:07 crazywhalecc

Hey @crazywhalecc, thanks for having an eye on this issue. Unfortunately, I can't help out with testing either. I changed my intel mac against an apple silicon mac recently.

buddhaCode avatar Jul 23 '25 07:07 buddhaCode

Is there a fix coming for this? I'm still running an Intel mac, and the SFTP adapter does not work.

jeffgreco13 avatar Aug 11 '25 02:08 jeffgreco13

Is there a fix coming for this? I'm still running an Intel mac, and the SFTP adapter does not work.

@jeffgreco13 It would be great if you could upload your local intel version of PHP binary to me. And I would be able to debug.

crazywhalecc avatar Aug 11 '25 03:08 crazywhalecc

@jeffgreco13 It would be great if you could upload your local intel version of PHP binary to me. And I would be able to debug.

PHP Version 8.4.10

Darwin MacBookPro 24.6.0 Darwin Kernel Version 24.6.0: Mon Jul 14 11:28:17 PDT 2025; root:xnu-11417.140.69~1/RELEASE_X86_64 x86_64

jeffgreco13 avatar Aug 11 '25 03:08 jeffgreco13

A few additional notes: I am using a freshly reformatted Intel Mac with a brand new install of Herd (Pro version). I deployed the code to a standard DigitalOcean server on Forge - no additional packages installed, just the default installation.

jeffgreco13 avatar Aug 11 '25 03:08 jeffgreco13

After full testing for static-php and Herd, this issue has been fixed in static-php-cli 2.6.1 and later versions, but the static-php-cli builder used by Herd is still 2.5.0. @mpociot may need to update it.

crazywhalecc avatar Aug 11 '25 04:08 crazywhalecc

This should now be fixed in the latest updates

mpociot avatar Sep 02 '25 07:09 mpociot