parcel segmentation fault 问题以及解决方法
parcel 是一个很不错的all-in-one 的简单工具,可以方便web 构建,因为使用mac 构建没有发现问题,但是在linux 上运行的时候
发现是有问题的,出现了段错误问题,尝试了几种解决方法(升级npm 、node,yarn 版本 )但是都没有解决,同时尝试使用了
strace 信息如下
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_SETMASK, ~[RTMIN RT_1], [], 8) = 0
read(4, "*", 1) = 1
rt_sigaction(SIGIO, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7eff95e58630}, NULL, 8) = 0
write(5, "*", 1) = 1
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_SETMASK, ~[RTMIN RT_1], [], 8) = 0
read(4, "*", 1) = 1
rt_sigaction(SIGPWR, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7eff95e58630}, NULL, 8) = 0
write(5, "*", 1) = 1
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_SETMASK, ~[RTMIN RT_1], [], 8) = 0
read(4, "*", 1) = 1
rt_sigaction(SIGSTKFLT, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7eff95e58630}, NULL, 8) = 0
write(5, "*", 1) = 1
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
rt_sigprocmask(SIG_SETMASK, ~[RTMIN RT_1], [], 8) = 0
read(4, "*", 1) = 1
rt_sigaction(SIGSYS, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7eff95e58630}, NULL, 8) = 0
write(5, "*", 1) = 1
rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
write(17, "", 0) = 0
futex(0x306c80c, FUTEX_CMP_REQUEUE_PRIVATE, 1, 2147483647, 0x306c7e0, 100) = 4
write(12, "\1\0\0\0\0\0\0\0", 8) = 8
futex(0x7eff95a7a9d0, FUTEX_WAIT, 30173, NULL) = -1 EAGAIN (Resource temporarily unavailable)
munmap(0x7eff9527a000, 8392704) = 0
epoll_ctl(3, EPOLL_CTL_ADD, 6, {EPOLLIN, {u32=6, u64=6}}) = 0
epoll_ctl(3, EPOLL_CTL_ADD, 8, {EPOLLIN, {u32=8, u64=8}}) = 0
epoll_wait(3, [], 1024, 0) = 0
close(6) = 0
close(7) = 0
close(8) = 0
close(3) = 0
fstat(0, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0),
fcntl(0, F_GETFL) = 0x8002 (flags O_RDWR|O_LARGEFILE)
rt_sigprocmask(SIG_BLOCK, [TTOU], NULL, 8) = 0
ioctl(0, SNDCTL_TMR_START or TCSETS, {B38400 opost isig icanon echo
ioctl(0, TCGETS, {B38400 opost isig icanon echo
rt_sigprocmask(SIG_UNBLOCK, [TTOU], NULL, 8) = 0
fstat(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0),
fcntl(1, F_GETFL) = 0x8002 (flags O_RDWR|O_LARGEFILE)
rt_sigprocmask(SIG_BLOCK, [TTOU], NULL, 8) = 0
ioctl(1, SNDCTL_TMR_START or TCSETS, {B38400 opost isig icanon echo
ioctl(1, TCGETS, {B38400 opost isig icanon echo
rt_sigprocmask(SIG_UNBLOCK, [TTOU], NULL, 8) = 0
fstat(2, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0),
fcntl(2, F_GETFL) = 0x8002 (flags O_RDWR|O_LARGEFILE)
rt_sigprocmask(SIG_BLOCK, [TTOU], NULL, 8) = 0
ioctl(2, SNDCTL_TMR_START or TCSETS, {B38400 opost isig icanon echo
ioctl(2, TCGETS, {B38400 opost isig icanon echo
rt_sigprocmask(SIG_UNBLOCK, [TTOU], NULL, 8) = 0
close(4) = 0
close(5) = 0
# 此处会有异常信息
futex(0x2c97aa4, FUTEX_WAKE_OP_PRIVATE, 1, 1, 0x2c97aa0, FUTEX_OP_SET<<28|0<<12|FUTEX_OP_CMP_GT<<24|0x1) = 1
futex(0x2c97a60, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7eff8effd9d0, FUTEX_WAIT, 30179, NULL) = 0
munmap(0x7eff94a79000, 8392704) = 0
munmap(0x7eff94278000, 8392704) = 0
munmap(0x7eff8f7ff000, 8392704) = 0
munmap(0x7eff8effe000, 8392704) = 0
exit_group(0) = ?
+++ exited with 0 +++
发现并不是很明确,就使用了perf 的trace 信息如下
1340.638 (43.568 ms): node/30376
1384.214 ( 0.008 ms): node/30376 futex(uaddr: 0x2c97aa4, op: WAKE_OP|PRIV, val: 1, utime: 0x1, uaddr2: 0x2c97aa0, val3: 0x4000001d) = 1
1384.226 ( 0.003 ms): node/30376 futex(uaddr: 0x2c97a60, op: WAKE|PRIV, val: 1 ) = 0
1384.236 ( 0.009 ms): node/30376 madvise(start: 0x7f096e8db000, len_in: 8368128, behavior: MADV_DONTNEED) = 0
1384.249 ( ): node/30376 exit( )
1340.722 (43.609 ms): node/30378
1384.337 ( 0.006 ms): node/30378 futex(uaddr: 0x2c97aa4, op: WAKE_OP|PRIV, val: 1, utime: 0x1, uaddr2: 0x2c97aa0, val3: 0x4000001d) = 1
1384.346 ( 0.003 ms): node/30378 futex(uaddr: 0x2c97a60, op: WAKE|PRIV, val: 1 ) = 0
1384.354 ( 0.007 ms): node/30378 madvise(start: 0x7f096d8d9000, len_in: 8368128, behavior: MADV_DONTNEED) = 0
1384.364 ( ): node/30378 exit( )
1341.178 (43.235 ms): node/30377
1384.417 ( 0.012 ms): node/30377 futex(uaddr: 0x2c97aa4, op: WAKE_OP|PRIV, val: 1, utime: 0x1, uaddr2: 0x2c97aa0, val3: 0x4000001d) = 1
1384.432 ( 0.003 ms): node/30377 futex(uaddr: 0x2c97a60, op: WAKE|PRIV, val: 1 ) = 0
1384.439 ( 0.005 ms): node/30377 madvise(start: 0x7f096e0da000, len_in: 8368128, behavior: MADV_DONTNEED) = 0
1384.447 ( ): node/30377 exit( )
307.570 (1077.301 ms): node/30373
? ( ): node/30355
1402.290 ( 0.004 ms): node/30355 read(fd: 12, buf: 0x7fc200eaa8d0, count: 1024 ) = 8
1402.305 ( 0.003 ms): node/30355 close(fd: 10 ) = 0
1402.314 ( 0.002 ms): node/30355 close(fd: 11 ) = 0
1402.324 ( 0.002 ms): node/30355 close(fd: 12 ) = 0
1402.331 ( 0.002 ms): node/30355 close(fd: 9 ) = 0
1402.341 ( 0.007 ms): node/30355 madvise(start: 0x7fc2006ae000, len_in: 8368128, behavior: MADV_DONTNEED) = 0
1402.351 ( ): node/30355 exit( )
281.999 (1121.739 ms): node/30362
1403.750 ( 0.008 ms): node/30362 futex(uaddr: 0x2c97aa4, op: WAKE_OP|PRIV, val: 1, utime: 0x1, uaddr2: 0x2c97aa0, val3: 0x4000001d) = 1
1403.760 ( 0.002 ms): node/30362 futex(uaddr: 0x2c97a60, op: WAKE|PRIV, val: 1 ) = 0
1403.766 ( 0.004 ms): node/30362 madvise(start: 0x7fc1f8ffa000, len_in: 8368128, behavior: MADV_DONTNEED) = 0
1403.772 ( ): node/30362 exit( )
282.093 (1121.731 ms): node/30364
1403.831 ( 0.009 ms): node/30364 futex(uaddr: 0x2c97aa4, op: WAKE_OP|PRIV, val: 1, utime: 0x1, uaddr2: 0x2c97aa0, val3: 0x4000001d) = 1
1403.842 ( 0.002 ms): node/30364 futex(uaddr: 0x2c97a60, op: WAKE|PRIV, val: 1 ) = 0
1403.846 ( 0.004 ms): node/30364 madvise(start: 0x7fc1eb7ff000, len_in: 8368128, behavior: MADV_DONTNEED) = 0
1403.852 ( ): node/30364 exit( )
13.769 (1390.637 ms): node/30360
是看到了一些眉目但是还是不确定如何解决,然后就github issue 搜了下,发现类似问题不少,从说明来说是关于source-map 插件的是和rust 集成有关系
解决方法
很简单,临时解决方法就是添加环境变量PARCEL_WORKER_BACKEND=process
问题临时解决了,rust 是不错,但是rust与外部集成也是有问题的(parcel
不少扩展使用了rust 扩展)
参考资料
https://github.com/parcel-bundler/parcel/issues/7598
https://github.com/parcel-bundler/source-map/pull/91