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

Mac M2芯片 docker 中运行出现Segmentation fault #2

Open
yeling opened this issue Jan 16, 2024 · 3 comments
Open

Mac M2芯片 docker 中运行出现Segmentation fault #2

yeling opened this issue Jan 16, 2024 · 3 comments

Comments

@yeling
Copy link

yeling commented Jan 16, 2024

关联的issue

具体的case 见umijs/umi#12013

Mac M2芯片,
macOS 13.6.3

docker镜像采用ubuntu:24.04

运行自己的项目和按照文档创建项目是同样的结果 https://umijs.org/docs/guides/getting-started

项目里面只有这个.node文件会在 npx umi setup阶段被使用,应该是这个文件的问题,希望能更新一下

@umijs/es-module-parser-linux-arm64-gnu/es-module-parser.linux-arm64-gnu.node

@stormslowly
Copy link
Member

stormslowly commented Jan 29, 2024

我尝试复现了下, 未能复现,对比了下环境, 我用的配置如下.
感觉唯一不同的是 macos 的版本,但是已经在 docker 环境中了,os 可能影响不大。

目前的建议是,

  1. 尝试升级下 node 到 18 试试,(我看 16 已经停止维护了)
  2. 给我一个其他的必现方式
  • ubuntu 的 images 如下:
REPOSITORY                                            TAG                  IMAGE ID       CREATED        SIZE
ubuntu                                                24.04                b62afbf00f1f   13 days ago    93.6MB
  • node node-v16.20.2-linux-arm64
  • MacOS 14.2.1 (23C71)

复现日志

# cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=24.04
DISTRIB_CODENAME=noble
DISTRIB_DESCRIPTION="Ubuntu Noble Numbat (development branch)"
# /home/ubuntu/test/16/node-v16.20.2-linux-arm64/bin/node
Welcome to Node.js v16.20.2.
Type ".help" for more information.
> x = require('./es-module-parser.linux-arm64-gnu.node')
{
  parseCode: [Function: parseCode],
  parseFiles: [Function: parseFiles],
  parseFilesSync: [Function: parseFilesSync]
}
> x.parseCode("import a from 'b'")
[
  {
    end: 18,
    importKind: 'value',
    source: 'b',
    specifiers: [ [Object] ],
    start: 1,
    type: 'ImportDeclaration'
  }
]
>

@fz6m
Copy link
Member

fz6m commented Jan 29, 2024

涉及到 docker 虚拟环境确实可能存在很多不确定性,建议升级一下 rust 的依赖,然后改一下 cargo build 参数重新构建发包一次试试? @stormslowly

目前通用的 napi cargo build 配置如下:

展开查看
# .cargo/config.toml

# macos
[target.x86_64-apple-darwin]
rustflags = ["-C", "link-arg=-undefined", "-C", "link-arg=dynamic_lookup"]

[target.aarch64-apple-darwin]
rustflags = ["-C", "link-arg=-undefined", "-C", "link-arg=dynamic_lookup"]

# windows
[target.x86_64-pc-windows-msvc]
linker = "rust-lld"
rustflags = ["-C", "target-feature=+crt-static"]

[target.aarch64-pc-windows-msvc]
linker = "rust-lld"
rustflags = ["-C", "target-feature=+crt-static"]

# linux
[target.x86_64-unknown-linux-gnu]
rustflags = ["-C", "target-feature=+sse2"]

[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
rustflags = []

[target.x86_64-unknown-linux-musl]
rustflags = ["-C", "target-feature=-crt-static"]

[target.aarch64-unknown-linux-musl]
linker = "aarch64-linux-musl-gcc"
rustflags = ["-C", "target-feature=-crt-static", "-C", "link-arg=-lgcc"]

[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"
rustflags = []

@yeling
Copy link
Author

yeling commented Jan 29, 2024

@stormslowly

我试了一下,node版本升级到18之后,就没有这个问题了,相关日志如下。
因为Umi文档里面推荐的16所以就直接用了16版本,没想到会跟这个有关系,非常感谢。
image

root@8053ce402874:/code/myapp# nvm use 16
Now using node v16.20.2 (npm v8.19.4)
root@8053ce402874:/code/myapp# npm run start

> start
> npm run dev


> dev
> umi dev

info  - [你知道吗?] 遇到难解的配置问题,试试从 Umi FAQ 中寻找答案,详见 https://umijs.org/docs/introduce/faq
info  - Umi v4.1.0
info  - Preparing...
root@8053ce402874:/code/myapp# nvm use 18
Now using node v18.19.0 (npm v10.2.3)
root@8053ce402874:/code/myapp# npm run start

> start
> npm run dev


> dev
> umi dev

info  - [你知道吗?] 想快速修改 html 模板、DIY 项目?试试编写项目级插件,详见 https://umijs.org/docs/guides/directory-structure#plugints
info  - Umi v4.1.0
info  - Preparing...
info  - MFSU eager strategy enabled
info  - [MFSU][eager] restored cache
event - [MFSU][eager] start build deps
info  - [MFSU] skip buildDeps
        ╔════════════════════════════════════════════════════╗
        ║ App listening at:                                  ║
        ║  >   Local: http://localhost:8000                  ║
ready - ║  > Network: http://172.17.0.2:8000                 ║
        ║                                                    ║
        ║ Now you can open browser with the above addresses↑ ║
        ╚════════════════════════════════════════════════════╝
info  - [MFSU][eager] worker init, takes 296ms
event - [Webpack] Compiled in 786 ms (355 modules)
wait  - [Webpack] Compiling...
event - [MFSU][eager] start build deps
info  - [MFSU] skip buildDeps
event - [Webpack] Compiled in 52 ms (341 modules)
^C^C
root@8053ce402874:/code/myapp# nvm ls
       v16.20.2
->     v18.19.0
default -> 16 (-> v16.20.2)
iojs -> N/A (default)
unstable -> N/A (default)
node -> stable (-> v18.19.0) (default)
stable -> 18.19 (-> v18.19.0) (default)
lts/* -> lts/iron (-> N/A)
lts/argon -> v4.9.1 (-> N/A)
lts/boron -> v6.17.1 (-> N/A)
lts/carbon -> v8.17.0 (-> N/A)
lts/dubnium -> v10.24.1 (-> N/A)
lts/erbium -> v12.22.12 (-> N/A)
lts/fermium -> v14.21.3 (-> N/A)
lts/gallium -> v16.20.2
lts/hydrogen -> v18.19.0
lts/iron -> v20.11.0 (-> N/A)
root@8053ce402874:/code/myapp#

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants