Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation fault opening vscode on Arch Linux ARM64 #153849

Closed
h0m3 opened this issue Jun 30, 2022 · 18 comments · Fixed by #154092
Closed

Segmentation fault opening vscode on Arch Linux ARM64 #153849

h0m3 opened this issue Jun 30, 2022 · 18 comments · Fixed by #154092
Assignees
Labels
author-verification-requested Issues potentially verifiable by issue author bug Issue identified by VS Code Team member as probable bug chromium Issues and items related to Chromium fixed-in-electron-19 Issues fixed with Electron 19.x update insiders-released Patch has been released in VS Code Insiders linux Issues with VS Code on Linux upstream-issue-fixed The underlying upstream issue has been fixed verified Verification succeeded
Milestone

Comments

@h0m3
Copy link

h0m3 commented Jun 30, 2022

Does this issue occur when all extensions are disabled?: Yes

Hello Friends,

I'm running vscode from Arch Linux ARM (Asahi) on my MacBook Air M1 and its giving me a segfault before it opens.

/opt/visual-studio-code/bin/code: line 62: 16644 Segmentation fault ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" --ms-enable-electron-run-as-node "$@"

I have never opened code before on this system and I think it may be related to the fact that the M1 uses a 16K address page (chromium had a similar issue and maybe a similar patch can be applied) instead of a 4K. More info in the Asahi wiki.

I know its a very niche case on a probably unsupported platform but since more ARM systems would start using pages bigger than the standard x86 4K for the big performance improvement it may be worth it the report.

  • VS Code Version: Both 1.68.1 and Insiders build 1656566876
  • OS Version: Arch Linux Asahi ARM64 (MacBook Air M1) - Linux 5.17.0-rc7-asahi-next-20220310-5-2-ARCH

Steps to Reproduce:

  1. Open visual studio code with command /usr/bin/code --unity-launch %F or simply code.
@marcan
Copy link

marcan commented Jun 30, 2022

This is fixed in Electron 19.0.0, while vscode is still on 18.3.5. It should start working once Electron is updated (unless there are other issues).

@weinand weinand assigned deepak1556 and unassigned weinand Jun 30, 2022
@deepak1556
Copy link
Contributor

deepak1556 commented Jul 1, 2022

The issue has been addressed in vscode insiders and the fix will also be available in 1.69.0 stable release next week , you can refer to #145527 (comment) for context.

@h0m3
Copy link
Author

h0m3 commented Jul 7, 2022

Hello Friends,

Today code 1.69.0 binary dropped on AUR and i was able to test and unfortunately both 1.69.0 and insiders build 1657150868-1 gave me the same segfault.

I was able to install electron trough npm and running code by forcing electron 19 trought npx electron /opt/visual-studio-code/resources/app --ms-enable-electron-run-as-node --unity-launch

@ayr-ton
Copy link

ayr-ton commented Jul 28, 2022

Could you folks confirm that 18.3.2 or more recent is being used? The issue persists in 1.69.0.

@ayr-ton
Copy link

ayr-ton commented Jul 28, 2022

Seems that 18.3.2 still has this issue. Testing with 19 to confirm.

@ayr-ton
Copy link

ayr-ton commented Jul 28, 2022

Confirmed that it's working with electron19 only. The issue persists. cc.: @deepak1556

@Lemmingh
Copy link
Contributor

Lemmingh commented Aug 1, 2022

@deepak1556

VS Code 1.69 did NOT fix this problem. It still sticks to 4 Ki.

To be successfully loaded, every Align of LOAD headers of a ELF file has to be equal to or greater than the system PAGESIZE.

Name Hex Dec
4 Ki 0x1000 4096
16 Ki 0x4000 16384
64 Ki 0x10000 65536

The AUR package simply points to the official VS Code release.

source_aarch64 = code_arm64_1.69.2.tar.gz::https://update.code.visualstudio.com/1.69.2/linux-arm64/stable
sha256sums_aarch64 = 9c53ff087ffcccda4ee0b210795bd95306a03824d668be6215c840341c0a4ffe

Let's check its program header.

readelf --program-headers ./code
Elf file type is DYN (Shared object file)
Entry point 0x1a45c80
There are 12 program headers, starting at offset 64

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  PHDR           0x0000000000000040 0x0000000000000040 0x0000000000000040
                 0x00000000000002a0 0x00000000000002a0  R      0x8
  INTERP         0x00000000000002e0 0x00000000000002e0 0x00000000000002e0
                 0x000000000000001b 0x000000000000001b  R      0x1
      [Requesting program interpreter: /lib/ld-linux-aarch64.so.1]
  LOAD           0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000001a44c5c 0x0000000001a44c5c  R      0x1000
  LOAD           0x0000000001a44c80 0x0000000001a45c80 0x0000000001a45c80
                 0x0000000005cb1540 0x0000000005cb1540  R E    0x1000
  LOAD           0x00000000076f61c0 0x00000000076f81c0 0x00000000076f81c0
                 0x0000000000512ba8 0x0000000000512ba8  RW     0x1000
  LOAD           0x0000000007c08d80 0x0000000007c0bd80 0x0000000007c0bd80
                 0x00000000000711f0 0x0000000000181fa0  RW     0x1000
  TLS            0x00000000076f61c0 0x00000000076f81c0 0x00000000076f81c0
                 0x0000000000000018 0x0000000000000120  R      0x8
  DYNAMIC        0x0000000007be52d8 0x0000000007be72d8 0x0000000007be72d8
                 0x00000000000003d0 0x00000000000003d0  RW     0x8
  GNU_RELRO      0x00000000076f61c0 0x00000000076f81c0 0x00000000076f81c0
                 0x0000000000512ba8 0x0000000000512e40  R      0x1
  GNU_EH_FRAME   0x0000000001a33460 0x0000000001a33460 0x0000000001a33460
                 0x000000000000349c 0x000000000000349c  R      0x4
  GNU_STACK      0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x0000000000000000 0x0000000000000000  RW     0x0
  NOTE           0x00000000000002fc 0x00000000000002fc 0x00000000000002fc
                 0x0000000000000064 0x0000000000000064  R      0x4

Evidently, it's 4 Ki-aligned, thus, cannot run on a 16 Ki system.


Meanwhile,

is also NOT fixed.

Chromium still does not support 64 Ki page size;

Thus, Electron doesn't;

Thus, VS Code doesn't.

@marcan
Copy link

marcan commented Aug 1, 2022

This is a different problem then. The Chromium bug related to internal support for >4K sizes in their allocator/etc. If the binary is being built with 4K segment alignment, that's a toolchain/build environment issue with the official VSCode binaries.

@Lemmingh
Copy link
Contributor

Lemmingh commented Aug 1, 2022

that's a toolchain/build environment issue

Yes, the problem is rooted in Electron v18, including the latest v18.3.6.

An app built with Electron v18 for Linux ARM64 is still 4 KiB-aligned.

In other words, the PR

doesn't work as expected, because it only backported the Chromium Change 3545665.

However, prior to that Change, there were modifications to Chromium's build system during M102, Change 3542265.

@deepak1556 deepak1556 reopened this Aug 1, 2022
@deepak1556
Copy link
Contributor

Thanks for the clarification @Lemmingh , I only backported the allocator CL that was linked in the chromium bug https://bugs.chromium.org/p/chromium/issues/detail?id=1301788, didn't know there was a compile time page size reduction that was checked in. We will be updating to Electron 19 this week which has the relevant compiler fixes #154092

@deepak1556 deepak1556 added bug Issue identified by VS Code Team member as probable bug linux Issues with VS Code on Linux upstream-issue-fixed The underlying upstream issue has been fixed chromium Issues and items related to Chromium fixed-in-electron-19 Issues fixed with Electron 19.x update labels Aug 1, 2022
@deepak1556 deepak1556 added this to the August 2022 milestone Aug 1, 2022
@ayr-ton
Copy link

ayr-ton commented Aug 1, 2022

@Lemmingh @deepak1556 You folks are awesome! Thanks for not giving up on the issue <3

@VSCodeTriageBot VSCodeTriageBot added unreleased Patch has not yet been released in VS Code Insiders insiders-released Patch has been released in VS Code Insiders and removed unreleased Patch has not yet been released in VS Code Insiders labels Aug 4, 2022
@mjbvz mjbvz added the author-verification-requested Issues potentially verifiable by issue author label Aug 24, 2022
@VSCodeTriageBot
Copy link
Collaborator

This bug has been fixed in the latest release of VS Code Insiders!

@h0m3, you can help us out by commenting /verified if things are now working as expected.

If things still don't seem right, please ensure you're on version 7ed02a6 of Insiders (today's or later - you can use Help: About in the command palette to check), and leave a comment letting us know what isn't working as expected.

Happy Coding!

@TylerLeonhardt
Copy link
Member

Can anyone here confirm that this is working again for them?

@deepak1556 I take it this is gonna be a hard one to verify if I don't have an Arch Linux ARM64 setup available 😅

@ayr-ton
Copy link

ayr-ton commented Aug 29, 2022

@TylerLeonhardt I can confirm!
It's working as expected now. Thanks :-)

@TylerLeonhardt TylerLeonhardt added the verified Verification succeeded label Aug 29, 2022
@Blebesquefee
Copy link

Hi ! I just tried to install vscode using this methode "https://linuxhint.com/install_visual_studio_code_arch_linux/" and i got this error "/opt/visual-studio-code/bin/code: line 62: 29630 Segmentation fault ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" --ms-enable-electron-run-as-node "$@"

Someone got any idea to resolve that ?

@h0m3
Copy link
Author

h0m3 commented Sep 14, 2022

Confirmed,

The issue is fixed. Sorry for the delayed response.

@h0m3
Copy link
Author

h0m3 commented Sep 14, 2022

Hi ! I just tried to install vscode using this methode "https://linuxhint.com/install_visual_studio_code_arch_linux/" and i got this error "/opt/visual-studio-code/bin/code: line 62: 29630 Segmentation fault ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" --ms-enable-electron-run-as-node "$@"

Someone got any idea to resolve that ?

Looks like the error of an older version, make sure you're trying to run the latest insiders. Probably the AUR you've followed in the tutorial is the stable version or its outdated.

@Blebesquefee
Copy link

Hi ! I just tried to install vscode using this methode "https://linuxhint.com/install_visual_studio_code_arch_linux/" and i got this error "/opt/visual-studio-code/bin/code: line 62: 29630 Segmentation fault ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" --ms-enable-electron-run-as-node "$@"
Someone got any idea to resolve that ?

Looks like the error of an older version, make sure you're trying to run the latest insiders. Probably the AUR you've followed in the tutorial is the stable version or its outdated.

Yeah thanks i was just trying to launch standard vscode and not insiders version. With the insider version all is perfectly fine. Thanks !

@github-actions github-actions bot locked and limited conversation to collaborators Sep 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
author-verification-requested Issues potentially verifiable by issue author bug Issue identified by VS Code Team member as probable bug chromium Issues and items related to Chromium fixed-in-electron-19 Issues fixed with Electron 19.x update insiders-released Patch has been released in VS Code Insiders linux Issues with VS Code on Linux upstream-issue-fixed The underlying upstream issue has been fixed verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants