dimkr / loksh

A Linux port of OpenBSD's ksh
117 stars 6 forks source link

internal error: j_set_async: bad nzombie (0) #22

Closed ko1nksm closed 4 years ago

ko1nksm commented 4 years ago

Hi,

I built as below.

$ docker run -it buildpack-deps
# apt-get update && apt-get install -y meson
# cd
# git clone https://github.com/dimkr/loksh.git
# cd loksh
# git checkout to-meson
# git branch -v
  master   7ffcafe Restore suspend
* to-meson 43795ed Allow use of ninja-compatible tools

# meson build
The Meson build system
Version: 0.49.2
Source dir: /root/loksh
Build dir: /root/loksh/build
Build type: native build
Project name: loksh
Project version: 6.7
Native C compiler: cc (gcc 8.3.0 "cc (Debian 8.3.0-6) 8.3.0")
Build machine cpu family: x86_64
Build machine cpu: x86_64
Submodule 'subprojects/lolibc' (https://github.com/dimkr/lolibc) registered for path 'lolibc'
Cloning into '/root/loksh/subprojects/lolibc'...
Submodule path 'lolibc': checked out '156bb299f545db7c2b7abeaf157462e7c8c16f69'

|
|Executing subproject lolibc
|
|Project name: lolibc
|Project version: 6.7
|Native C compiler: cc (gcc 8.3.0 "cc (Debian 8.3.0-6) 8.3.0")
|Checking for function "strlcpy" : NO
|Checking for function "strlcat" : NO
|Checking for function "issetugid" : NO
|Has header "sys/auxv.h" : YES
|Has header "sys/cdefs.h" : YES
|Header <signal.h> has symbol "sys_siglist" : YES
|Header <signal.h> has symbol "sys_signame" : NO
|Build targets in project: 2
|
|Subproject lolibc finished.
Found pkg-config: /usr/bin/pkg-config (0.29)
Dependency ncurses found: YES 6.1.20181013
Build targets in project: 3
Found ninja-1.8.2 at /usr/bin/ninja

# make
ninja -C build
ninja: Entering directory `build'
[10/37] Compiling C object 'ksh@exe/c_ksh.c.o'.
../c_ksh.c: In function 'c_cd':
../c_ksh.c:26:8: warning: variable 'xp' set but not used [-Wunused-but-set-variable]
  char *xp;
        ^~
[24/37] Compiling C object 'ksh@exe/lex.c.o'.
../lex.c: In function 'pushs':
../lex.c:966:9: warning: variable 'dummy' set but not used [-Wunused-but-set-variable]
   char *dummy;
         ^~~~~
[37/37] Linking target ksh.

Then I ran the command in the background, I got the following error:

# ./build/ksh
# echo &
./build/ksh: internal error: j_set_async: bad nzombie (0)
[1] 629

No problem with OpenBSD 6.6 sh

dimkr commented 4 years ago

Thanks for the report! Does this happen with 6.7 too (git checkout 6.7)?

ko1nksm commented 4 years ago

I'm not familiar with meson so I could not build on the 6.7 branch.

I originally noticed this bug on Alpine Linux on Docker. The version of loksh on Alpine Linux 3.12. is 6.7.1.

$ docker run -it alpine
/ # apk add loksh
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.12/community/x86_64/APKINDEX.tar.gz
(1/3) Installing ncurses-terminfo-base (6.2_p20200523-r0)
(2/3) Installing ncurses-libs (6.2_p20200523-r0)
(3/3) Installing loksh (6.7.1-r0)
Executing loksh-6.7.1-r0.post-install
Executing busybox-1.31.1-r16.trigger
OK: 7 MiB in 17 packages
/ # ksh
00b3d3256716# echo &
ksh: internal error: j_set_async: bad nzombie (0)
[1] 12
00b3d3256716#

The same is true for loksh 6.0 on Alpine Linux 3.5.

$ docker run -it alpine:3.5
/ # apk add --update loksh
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.5/community/x86_64/APKINDEX.tar.gz
(1/1) Installing loksh (6.0-r0)
Executing loksh-6.0-r0.post-install
Executing busybox-1.25.1-r2.trigger
OK: 4 MiB in 12 packages
/ # ksh
# echo &
ksh: internal error: j_async: bad nzombie (0)
[1] 12
ko1nksm commented 4 years ago

FYI, A workaround on the shell script side.

$ foo() { echo stderr >&2; }
$ { foo 2>&3 & } 3>&2 2>/dev/null
stderr 
dimkr commented 4 years ago

Fixed in master. Thank you!