for-mac icon indicating copy to clipboard operation
for-mac copied to clipboard

Segmentation fault on x86_64 with MacOS Virtualization Framework enabled

Open antoniofrignani opened this issue 2 years ago • 101 comments

  • [X] I have tried with the latest version of Docker Desktop
  • [X] I have tried disabling enabled experimental features
  • [X] I have uploaded Diagnostics
  • Diagnostics ID: 42EDF249-C0A8-4A3B-A709-4B2ADD41E5EF/20230505143852

Expected behavior

After a fresh local install of a Laravel project + Breeze (Vue), trying to build for production (sail npm run build) or starting a local hmr server (sail npm run dev) should work properly (using Docker for Mac on Intel Chip, v4.19.0)

Actual behavior

Both commands thows a Segmentation Fault error without further info.

  VITE v4.3.3  ready in 727 ms

  ➜  Local:   http://localhost:5173/
  ➜  Network: http://172.240.7.5:5173/
  ➜  press h to show help

  LARAVEL v10.9.0  plugin v0.7.4

  ➜  APP_URL: http://mysite.test
Segmentation fault

Information

Switching back to Docker for Mac v4.18.0 works as expected.

Possible workaround: disable Virtualization framework on v4.19+

Steps to reproduce the behavior

  1. Create a fresh Laravel project (curl -s "https://laravel.build/example-app" | bash)
  2. Install Laravel Breeze package (https://laravel.com/docs/10.x/starter-kits#laravel-breeze-installation) with the Vue stack
  3. Run sail npm run dev should throw the Segmentation Fault error

antoniofrignani avatar May 01 '23 21:05 antoniofrignani

@antoniofrignani, would it be possible to submit a diagnostic report and then add the Diagnostics ID here?

MihaelaStoica avatar May 03 '23 10:05 MihaelaStoica

@MihaelaStoica i've just updated my comment with a diagnostic ID

antoniofrignani avatar May 05 '23 14:05 antoniofrignani

I also have this issue.

There is no need to create a full Laravel project though. Installing Vite is enough to reproduce this issue:

  • Create a new Vite project via docker run -it --rm -v "$PWD":/usr/src/app -w /usr/src/app node npm create vite@latest
  • Change directory into the new Vite project: cd vite-project
  • Install the Vite package via npm: docker run -it --rm -v "$PWD":/usr/src/app -w /usr/src/app node npm install
  • Build for production or start a local hmr server: docker run -it --rm -v "$PWD":/usr/src/app -w /usr/src/app node npm run dev / docker run -it --rm -v "$PWD":/usr/src/app -w /usr/src/app node npm run build

Downgrading to 4.18.0 via https://docs.docker.com/desktop/release-notes/#4180 without changing the version of Vite is also a working workaround for me.

I also have access to a MacBook of a different model where this issue does not occur, so this might be hard to reproduce.

Specs of the MacBook that has the issue:

13" MacBook Pro 2020
CPU: 2,3GHz Quad-Core Intel Core i7
RAM: 16 GB 3733 MHz LPDDR4X 
OS: Ventura 13.3.1 (a)

Specs of the MacBook without the issue:

15" MacBook Pro 2017
CPU: 2,9GHz Quad-Core Intel Core i7
RAM: 16 GB 2133 MHz LPDDR3
OS: Ventura 13.3.1 (a)

irobin591 avatar May 08 '23 13:05 irobin591

I reported this issue to the yarn project (in hindsight not sure if I should have filed it here or at the node project instead). This issue here looks very similar to what I reported at https://github.com/yarnpkg/berry/issues/5420. The issue at the yarn repository contains a minimal case to reproduce.

For me, this issue happens 100% of the time, for coworkers (almost identical hardware) it does not fail at all.

tisba avatar May 08 '23 18:05 tisba

@irobin591 yes the issue is not direcly related to the framework itself, thanks for reproducing it with bare minimum boilerplate.

I'll watch the issue on the node/yarn side too since this seems strictly related, thanks @tisba for reporting it here.

antoniofrignani avatar May 09 '23 07:05 antoniofrignani

I can confirm that downgrading to Docker Desktop 4.18.0 (104112) fixes the issue for yarn install seg fauting (see comment above). Thanks for the hint @irobin591 - I can at least build assets again :)

Update I only see the issue on x86. On arm64 (macOS 13.3.1 (a) (22E772610a)) Docker Desktop 4.19.0 works fine, without segmentation fault. So it looks like 4.19.0 broke something specifically on Intel.

I use this to test:

#!/bin/sh

# run via
#
#   docker run -it --rm -v "$(pwd)/test.sh":/app/test.sh:ro -w /app node:18.16 /app/test.sh

set -e

cat << EOF > ./package.json
{
    "packageManager": "[email protected]",
    "dependencies": {
        "@rails/ujs": "7.0.4"
    }
}
EOF

corepack enable

npm install -g [email protected]

printf "uname -a: %s\n" "$(uname -a)"
printf "Node version: %s\n" "$(node --version)"
printf "Yarn version: %s\n" "$(yarn --version)"
printf "npm version: %s\n" "$(npm --version)"
printf "\n\n"

printf "Running: yarn install\n"

yarn install

tisba avatar May 11 '23 17:05 tisba

@sam-thibault @MihaelaStoica: Can we provide something else to help with acknowledging/analysing the issue? (looking at the status/0-more-info-needed label)

tisba avatar May 16 '23 17:05 tisba

I have the same problem on a Laravel project with sail when I do the command sail npm run dev I get :

dev vite

Segmentation fault

Docker version 23.0.5, build bc4487a Docker Compose version v2.17.3 Node v18.16.0 NPM 9.6.7

julienallexandre avatar May 23 '23 07:05 julienallexandre

In case you missed it, @julienallexandre, downgrading Docker Desktop one version seems to help until the issue is identified and fixed.

tisba avatar May 23 '23 22:05 tisba

@tisba thanks yes that's what I did :)

julienallexandre avatar May 24 '23 06:05 julienallexandre

Ran into the same issue today. I was using: Node v19 Yarn 3.5.0 2.3 GHz Quad-Core Intel Core i7 Docker 4.19.0 & 4.20.1

I continually ran into silently failing yarn installs. Eventually, I tried a yarn install in the Docker terminal itself and received a seg fault.

Shoutout to you @tisba - I was losing my mind all afternoon.

Please fix this issue. @docker-robot

doyeka avatar Jun 06 '23 21:06 doyeka

I can confirm that with Docker Desktop 4.20.1 (110738) the problem persists under x86 (macOS 13.3.1 (a) (22E772610a)).

None of my Apple Silicon devices show this problem, also tested with latest Docker Desktop 4.20.1. Update I also can't get it to crash on Apple Silicon using Rosetta x86 emulation.

tisba avatar Jun 07 '23 17:06 tisba

I have same problem on i9 intel iMac. I can reproduce on latest docker desktop. Downgrading to 4.18 fixes issue but has networking problems of its own on Ventura 13.4.

Interestingly, I can reproduce with node v18 and 20 buster/bullseye images. However node v16 works fine.

sergioharo avatar Jun 10 '23 04:06 sergioharo

Updated to macOS 13.4 (22F66) and the problem still persists.

tisba avatar Jun 13 '23 09:06 tisba

As an added piece of information... I have 2 development setups I am currently working in and experiencing this same issue. I am using the bullseye images for my containers.

  • Home: i9 Intel iMac, node versions v14, v16, v17 can build successfully, v18-20 results in seg fault
  • Work: i5 Intel iMac, node versions v14-20 can all build successfully

Both machines are running: macOS 13.4 / Docker Desktop v4.20.1 / Node v18.16.0

charlon avatar Jun 14 '23 16:06 charlon

Same problem with version 4.20.1, reverting to v 4.18 is the only working workaround afaik

antoniofrignani avatar Jun 19 '23 23:06 antoniofrignani

I had same issue.

MacBook Pro (13-inch, 2020, Four Thunderbolt 3 ports) Monterey 12.6.2 Intel Core i7

But it's fixed after downgraded to 4.18.0 without any changes of dockerfile, thank you.

taro-ishihara avatar Jun 21 '23 06:06 taro-ishihara

I had the same issue, but I use Laravel Mix instead of Vite. Downgrading Docker desktop to 4.18.0 did also the trick for me.

RogierW avatar Jun 22 '23 19:06 RogierW

Still preproducable with 4.21.0 (113844) on Ventura 13.4.1 (22F82). Do the issue labels need to be updated to reflect that the bug is still present, @sam-thibault?

tisba avatar Jul 03 '23 13:07 tisba

Managed to reproduce the issue on macOS Ventura 13.4.1 (22F82) with Docker Desktop 4.20.1 (110738) and Docker version 24.0.2, build cb74dfc

Tynael avatar Jul 03 '23 13:07 Tynael

Problem still relevant with latest 4.21.1 version

antoniofrignani avatar Jul 11 '23 13:07 antoniofrignani

@antoniofrignani confirming as well the issue is still relevant on 4.21.1 with an Intel Mac.

KFoxder avatar Jul 14 '23 18:07 KFoxder

any update for Docker 4.21.1 with Intel mac?

sotatek-manhnguyen8 avatar Jul 26 '23 03:07 sotatek-manhnguyen8

any update for Docker 4.21.1 with Intel mac?

yarn still crashing on 4.21.1

MajesticGray avatar Jul 26 '23 07:07 MajesticGray

Same issue on this laptop, still failing:

13" MacBook Pro 2020
CPU: 2GHz Quad-Core Intel Core i5
RAM: 16 GB 3733 MHz LPDDR4X 
OS: Ventura 13.2.1

Both Vite and Vitest were returning Segmentation fault. I tried everything I could think of and the only thing that actually worked was downgrading Docker from v4.21.1 to v4.18.0 - Thank you guys so much!

I was using npm though, not yarn. The error looked like this:

2023-07-31 16:33:29 > vite --debug
2023-07-31 16:33:29 
2023-07-31 16:33:31 npm ERR! path /home/app/frontend
2023-07-31 16:33:31 npm ERR! command failed
2023-07-31 16:33:31 npm ERR! signal SIGSEGV
2023-07-31 16:33:31 npm ERR! command sh -c -- vite --debug
2023-07-31 16:33:31 
2023-07-31 16:33:31 npm ERR! A complete log of this run can be found in:

pablo-psi avatar Aug 01 '23 09:08 pablo-psi

+1

Experiencing this issue with a laravel project using npm with vite.

Can confirm that downgrading to v4.18.0 fixes the issue for some reason.

kamst01 avatar Aug 01 '23 18:08 kamst01

@sam-thibault is this somehow on the radar. I am following this ticket for quiet some time and just like anyone here I am stuck on the last working release.

I suppose nobody found the root cause yet but might be easier for a docker dev to debug where that segfault comes from.

8de2fdb0 avatar Aug 01 '23 20:08 8de2fdb0

I've had a similar issue with running the AWS cdk inside containers under Docker Desktop on Mac. After attempting the version downgrade without success. I tried un-checking "Use Virtualization framework" and this appears to have resolved my issues. It may be worth trying here since AWS cdk is a nodejs package there could be a common thread there.

AbbyRH avatar Aug 02 '23 14:08 AbbyRH

I've had a similar issue with running the AWS cdk inside containers under Docker Desktop on Mac. After attempting the version downgrade without success. I tried un-checking "Use Virtualization framework" and this appears to have resolved my issues. It may be worth trying here since AWS cdk is a nodejs package there could be a common thread there.

I've been monitoring this thread for a while and this solution proposed by @AbbyRH is the first one that solves the issue, I'm running Docker Desktop for Mac v4.21.1 (114176) and I'm finally able to run Vite without the seg fault error, thanks @AbbyRH!

everdaniel avatar Aug 02 '23 15:08 everdaniel

Confirmed that the problem is somewhere in-between Docker Engine and MacOS Virtualization Framework, it now works disabling the latter on v 4.22.

This seems to be the only working workaround as of now. Thanks @AbbyRH for sharing your solution.

antoniofrignani avatar Aug 07 '23 13:08 antoniofrignani