dimkr / loksh

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

"kill -l" cause Segmentation falt #24

Closed ko1nksm closed 3 years ago

ko1nksm commented 3 years ago
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
23db820375a4# kill -l
Segmentation fault

Sorry. I should have remembered this a little earlier.

dimkr commented 3 years ago

Thanks for the report. I'm on it.

ko1nksm commented 3 years ago

Thanks for quick fixes!

dimkr commented 3 years ago

Cheers @ko1nksm, keep the bugs coming :)

ko1nksm commented 3 years ago

Hi, @dimkr

Unfortunately, This fix caused kill -l signal broken.

Before (6.7.1):

$ kill -l 1
HUP

After (6.7.4):

$ kill -l 1
1)

And the list is somehow weird. 😖

# kill -l
 1     1) Hangup                             23    12) Urgent I/O condition               45    23) RT45
 2    HUP Interrupt                          24   USR2 CPU time limit exceeded            46    URG RT46
 3     2) Quit                               25    13) File size limit exceeded           47    24) RT47
 4    INT Illegal instruction                26   PIPE Virtual timer expired              48   XCPU RT48
 5     3) Trace/breakpoint trap              27    14) Profiling timer expired            49    25) RT49
 6   QUIT Aborted                            28   ALRM Window changed                     50   XFSZ RT50
 7     4) Bus error                          29    15) I/O possible                       51    26) RT51
 8    ILL Arithmetic exception               30   TERM Power failure                      52 VTALRM RT52
 9     5) Killed                             31    16) Bad system call                    53    27) RT53
10   TRAP User defined signal 1              32 STKFLT RT32                               54   PROF RT54
11     6) Segmentation fault                 33    17) RT33                               55    28) RT55
12   ABRT User defined signal 2              34   CHLD RT34                               56  WINCH RT56
13     7) Broken pipe                        35    18) RT35                               57    29) RT57
14    BUS Alarm clock                        36   CONT RT36                               58   POLL RT58
15     8) Terminated                         37    19) RT37                               59    30) RT59
16    FPE Stack fault                        38   STOP RT38                               60    PWR RT60
17     9) Child process status               39    20) RT39                               61    31) RT61
18   KILL Continued                          40   TSTP RT40                               62    SYS RT62
19    10) Stopped (signal)                   41    21) RT41                               63    35) RT63
20   USR1 Stopped                            42   TTIN RT42                               64  RTMIN RT64
21    11) Stopped (tty input)                43    22) RT43
22   SEGV Stopped (tty output)               44   TTOU RT44

FYI, Yet another port of OpenBSD ksh, oksh:

# oksh
# kill -l
 1     HUP Hangup                            23     URG Urgent I/O condition              45 UNKNOWN RT45
 2     INT Interrupt                         24    XCPU CPU time limit exceeded           46 UNKNOWN RT46
 3    QUIT Quit                              25    XFSZ File size limit exceeded          47 UNKNOWN RT47
 4     ILL Illegal instruction               26  VTALRM Virtual timer expired             48 UNKNOWN RT48
 5    TRAP Trace/breakpoint trap             27    PROF Profiling timer expired           49 UNKNOWN RT49
 6    ABRT Aborted                           28   WINCH Window changed                    50 UNKNOWN RT50
 7     BUS Bus error                         29      IO I/O possible                      51 UNKNOWN RT51
 8     FPE Arithmetic exception              30     PWR Power failure                     52 UNKNOWN RT52
 9    KILL Killed                            31     SYS Bad system call                   53 UNKNOWN RT53
10    USR1 User defined signal 1             32 UNKNOWN RT32                              54 UNKNOWN RT54
11    SEGV Segmentation fault                33 UNKNOWN RT33                              55 UNKNOWN RT55
12    USR2 User defined signal 2             34 UNKNOWN RT34                              56 UNKNOWN RT56
13    PIPE Broken pipe                       35 UNKNOWN RT35                              57 UNKNOWN RT57
14    ALRM Alarm clock                       36 UNKNOWN RT36                              58 UNKNOWN RT58
15    TERM Terminated                        37 UNKNOWN RT37                              59 UNKNOWN RT59
16  STKFLT Stack fault                       38 UNKNOWN RT38                              60 UNKNOWN RT60
17    CHLD Child process status              39 UNKNOWN RT39                              61 UNKNOWN RT61
18    CONT Continued                         40 UNKNOWN RT40                              62 UNKNOWN RT62
19    STOP Stopped (signal)                  41 UNKNOWN RT41                              63 UNKNOWN RT63
20    TSTP Stopped                           42 UNKNOWN RT42                              64 UNKNOWN RT64
21    TTIN Stopped (tty input)               43 UNKNOWN RT43
22    TTOU Stopped (tty output)              44 UNKNOWN RT44
dimkr commented 3 years ago

And the list is somehow weird.

Yes, it looks weird. It's because of a difference between Alpine and Debian (the output of kill -l, used during build). Will fix soon.

ko1nksm commented 3 years ago

I see.

BTW, We may also need to be aware of the CentOS output of /bin/kill -l (RT<N> RTMIN+<N> RTMAX-<N>).

$ docker run -it centos /bin/kill -l
HUP INT QUIT ILL TRAP ABRT IOT BUS FPE KILL USR1 SEGV USR2 PIPE ALRM
TERM STKFLT CHLD CLD CONT STOP TSTP TTIN TTOU URG XCPU XFSZ VTALRM PROF
WINCH IO POLL PWR SYS RT<N> RTMIN+<N> RTMAX-<N>