Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

application crash during WINCH Signal

by hanspr (Sexton)
on Nov 28, 2019 at 05:03 UTC ( [id://11109349]=perlquestion: print w/replies, xml ) Need Help??

hanspr has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

My apologies if I'm breaking a rule from your forum with this question.

I've been helping a github project asbru-cm / gtk3 branch, written en perl and gtk3.

The application is a connection manager for : ssh, rdp, telnet, etc. With some useful options like clustering connections.

Many years back known as PAC Manager

We have a very strange and challenging bug to solve, I have already spent 2 weeks and I'm not getting any closer to solve it.

I need some information on how to be able to debug this or guide me through the process, or If by any chance anyone has had a similar problem with the WINCH signal.

You may find the transcripts of the bug on this thread

Issue #232

The summary is this:

The original code located at : pac_conn
If I comment the following code, the application session does not dies, but we loose terminal resize functionality.

$SIG{'WINCH'} = sub { if (!$CONNECTED) { return 1; } while (! $EXP -> slave) { select(undef, undef, undef, 0.25); }; $EXP -> slave -> clone_winsize_from(\*STDIN); kill WINCH => $EXP -> pid if $EXP -> pid; };
The code comes from example use in the module Expect
  • The application executes correctly on any linux desktop environment, except : xubuntu 19.2
    • This means that the bug does not show in any other distribution but this one, on a clean install
    • I have a virtual machine where to reproduce the problem and I tried to uploaded the xubuntu.vdi file but is 7Gb and It takes hours to upload I had to quit the attempt.
  • To reproduce.
    • Create a new virtual machine with : xubuntu 19.2
    • Clone the gtk3 branch, install all dependencies with apt or cpanm
    • run asbru-cm
    • Clic on the local terminal icon (is on the lower bar of icons and it looks like a terminal)
    • Shrink the window and the terminal disconnects (more detailed images are in the next point)
  • It actually happened to me first on Linux Mint, and I made the first report of it on this thread Issue #216
    I created a new user in my machine, and the problem disappeared, so I blame it to an environment issue related to the recent upgrade I did. And I still think it is environment issue, but have no clue to know what is it and how could be handled.

I have used strace on the process that gets killed and this is what I got, but I do not see how to use the information to get closer to the problem.
During the first part I resize (enlarge) the window and it can be seen the terminal receives the SGWINCH signal and the size, correctly.
When I begin to shrink it, suddenly an IO/ERROR is genereted an the hup sugnal is sent to the terminal and closes.

I separated the lines to show the moment it happens.

strace: Process 1467 attached
21:01:07.691091 pselect6(1, [0], NULL, NULL, NULL, {[], 8}) = ? ERESTARTNOHAND (To be restarted if no handler)
21:01:20.484590 --- SIGWINCH {si_signo=SIGWINCH, si_code=SI_USER, si_pid=1460, si_uid=1000} ---
21:01:20.484731 rt_sigreturn({mask=[]}) = -1 EINTR (Llamada al sistema interrumpida)
21:01:20.485366 ioctl(0, TIOCGWINSZ, {ws_row=25, ws_col=85, ws_xpixel=0, ws_ypixel=0}) = 0
21:01:20.485743 write(2, "\r\33K\330;test@test-VirtualBox: ~\7"..., 82) = 82
21:01:20.485844 pselect6(1, [0], NULL, NULL, NULL, {[], 8}) = ? ERESTARTNOHAND (To be restarted if no handler)
21:01:20.670434 --- SIGWINCH {si_signo=SIGWINCH, si_code=SI_USER, si_pid=1460, si_uid=1000} ---
21:01:20.670485 rt_sigreturn({mask=[]}) = -1 EINTR (Llamada al sistema interrumpida)
21:01:20.670576 ioctl(0, TIOCGWINSZ, {ws_row=26, ws_col=85, ws_xpixel=0, ws_ypixel=0}) = 0
21:01:20.670644 write(2, "\r\33K\330;test@test-VirtualBox: ~\7"..., 82) = 82
21:01:20.670754 pselect6(1, [0], NULL, NULL, NULL, {[], 8}) = ? ERESTARTNOHAND (To be restarted if no handler)
21:01:21.463879 --- SIGWINCH {si_signo=SIGWINCH, si_code=SI_USER, si_pid=1460, si_uid=1000} ---
21:01:21.463975 rt_sigreturn({mask=[]}) = -1 EINTR (Llamada al sistema interrumpida)
21:01:21.464092 ioctl(0, TIOCGWINSZ, {ws_row=27, ws_col=85, ws_xpixel=0, ws_ypixel=0}) = 0
21:01:21.464213 write(2, "\r\33K\330;test@test-VirtualBox: ~\7"..., 82) = 82
21:01:21.464488 pselect6(1, [0], NULL, NULL, NULL, {[], 8}) = ? ERESTARTNOHAND (To be restarted if no handler)
21:01:22.121628 --- SIGWINCH {si_signo=SIGWINCH, si_code=SI_USER, si_pid=1460, si_uid=1000} ---
21:01:22.121696 rt_sigreturn({mask=[]}) = -1 EINTR (Llamada al sistema interrumpida)
21:01:22.121782 ioctl(0, TIOCGWINSZ, {ws_row=28, ws_col=85, ws_xpixel=0, ws_ypixel=0}) = 0
21:01:22.121878 write(2, "\r\33K\330;test@test-VirtualBox: ~\7"..., 82) = 82
21:01:22.121964 pselect6(1, [0], NULL, NULL, NULL, {[], 8}) = ? ERESTARTNOHAND (To be restarted if no handler)
21:01:22.346570 --- SIGWINCH {si_signo=SIGWINCH, si_code=SI_USER, si_pid=1460, si_uid=1000} ---
21:01:22.346630 rt_sigreturn({mask=[]}) = -1 EINTR (Llamada al sistema interrumpida)
21:01:22.346702 ioctl(0, TIOCGWINSZ, {ws_row=29, ws_col=85, ws_xpixel=0, ws_ypixel=0}) = 0
21:01:22.346788 write(2, "\r\33K\330;test@test-VirtualBox: ~\7"..., 82) = 82
21:01:22.346867 pselect6(1, [0], NULL, NULL, NULL, {[], 8}) = ? ERESTARTNOHAND (To be restarted if no handler)
21:01:23.782493 --- SIGWINCH {si_signo=SIGWINCH, si_code=SI_USER, si_pid=1460, si_uid=1000} ---
21:01:23.782719 rt_sigreturn({mask=[]}) = -1 EINTR (Llamada al sistema interrumpida)
21:01:23.782866 ioctl(0, TIOCGWINSZ, {ws_row=27, ws_col=82, ws_xpixel=0, ws_ypixel=0}) = 0
21:01:23.782993 write(2, "\r\33K\330;test@test-VirtualBox: ~\7"..., 82) = 82
21:01:23.783095 pselect6(1, [0], NULL, NULL, NULL, {[], 8}) = ? ERESTARTNOHAND (To be restarted if no handler)
21:01:23.784337 --- SIGWINCH {si_signo=SIGWINCH, si_code=SI_USER, si_pid=1460, si_uid=1000} ---
21:01:23.784411 rt_sigreturn({mask=[]}) = -1 EINTR (Llamada al sistema interrumpida)
21:01:23.784514 ioctl(0, TIOCGWINSZ, {ws_row=28, ws_col=85, ws_xpixel=0, ws_ypixel=0}) = 0
21:01:23.784624 write(2, "\r\33K\330;test@test-VirtualBox: ~\7"..., 82) = 82
21:01:23.785580 pselect6(1, [0], NULL, NULL, NULL, {[], 8}) = ? ERESTARTNOHAND (To be restarted if no handler)
21:01:24.098243 --- SIGWINCH {si_signo=SIGWINCH, si_code=SI_USER, si_pid=1460, si_uid=1000} ---
21:01:24.098288 rt_sigreturn({mask=[]}) = -1 EINTR (Llamada al sistema interrumpida)
21:01:24.098342 ioctl(0, TIOCGWINSZ, {ws_row=27, ws_col=85, ws_xpixel=0, ws_ypixel=0}) = 0
21:01:24.098397 write(2, "\r\33K\330;test@test-VirtualBox: ~\7"..., 82) = 82
21:01:24.098449 pselect6(1, [0], NULL, NULL, NULL, {[], 8}) = ? ERESTARTNOHAND (To be restarted if no handler)
21:01:24.657126 --- SIGWINCH {si_signo=SIGWINCH, si_code=SI_USER, si_pid=1460, si_uid=1000} ---
21:01:24.657237 rt_sigreturn({mask=[]}) = -1 EINTR (Llamada al sistema interrumpida)
21:01:24.657484 ioctl(0, TIOCGWINSZ, {ws_row=26, ws_col=85, ws_xpixel=0, ws_ypixel=0}) = 0
21:01:24.657886 write(2, "\r\33K\330;test@test-VirtualBox: ~\7"..., 82) = 82
21:01:24.658059 pselect6(1, [0], NULL, NULL, NULL, {[], 8}) = ? ERESTARTNOHAND (To be restarted if no handler)
21:01:24.916138 --- SIGWINCH {si_signo=SIGWINCH, si_code=SI_USER, si_pid=1460, si_uid=1000} ---
21:01:24.916197 rt_sigreturn({mask=[]}) = -1 EINTR (Llamada al sistema interrumpida)
21:01:24.916302 ioctl(0, TIOCGWINSZ, {ws_row=25, ws_col=85, ws_xpixel=0, ws_ypixel=0}) = 0
21:01:24.916366 write(2, "\r\33K\330;test@test-VirtualBox: ~\7"..., 82) = 82
21:01:24.916417 pselect6(1, [0], NULL, NULL, NULL, {[], 8}) = ? ERESTARTNOHAND (To be restarted if no handler)
21:01:25.176208 --- SIGWINCH {si_signo=SIGWINCH, si_code=SI_USER, si_pid=1460, si_uid=1000} ---
21:01:25.176274 rt_sigreturn({mask=[]}) = -1 EINTR (Llamada al sistema interrumpida)
21:01:25.176346 ioctl(0, TIOCGWINSZ, {ws_row=24, ws_col=85, ws_xpixel=0, ws_ypixel=0}) = 0
21:01:25.176417 write(2, "\r\33K\330;test@test-VirtualBox: ~\7"..., 82) = 82
21:01:25.176474 pselect6(1, [0], NULL, NULL, NULL, {[], 8}) = ? ERESTARTNOHAND (To be restarted if no handler)
21:01:25.514431 --- SIGWINCH {si_signo=SIGWINCH, si_code=SI_USER, si_pid=1460, si_uid=1000} ---
21:01:25.514524 rt_sigreturn({mask=[]}) = -1 EINTR (Llamada al sistema interrumpida)
21:01:25.514629 ioctl(0, TIOCGWINSZ, {ws_row=23, ws_col=85, ws_xpixel=0, ws_ypixel=0}) = 0
21:01:25.514732 write(2, "\r\33K\330;test@test-VirtualBox: ~\7"..., 82) = 82
21:01:25.514823 pselect6(1, [0], NULL, NULL, NULL, {[], 8}) = ? ERESTARTNOHAND (To be restarted if no handler)
21:01:25.883280 --- SIGWINCH {si_signo=SIGWINCH, si_code=SI_USER, si_pid=1460, si_uid=1000} ---
21:01:25.883326 rt_sigreturn({mask=[]}) = -1 EINTR (Llamada al sistema interrumpida)
21:01:25.883383 ioctl(0, TIOCGWINSZ, {ws_row=22, ws_col=85, ws_xpixel=0, ws_ypixel=0}) = 0
21:01:25.883487 write(2, "\r\33K\330;test@test-VirtualBox: ~\7"..., 82) = 82
21:01:25.883629 pselect6(1, [0], NULL, NULL, NULL, {[], 8}) = ? ERESTARTNOHAND (To be restarted if no handler)
21:01:26.067849 --- SIGWINCH {si_signo=SIGWINCH, si_code=SI_USER, si_pid=1460, si_uid=1000} ---
21:01:26.067955 rt_sigreturn({mask=[]}) = -1 EINTR (Llamada al sistema interrumpida)
21:01:26.068159 ioctl(0, TIOCGWINSZ, {ws_row=21, ws_col=85, ws_xpixel=0, ws_ypixel=0}) = 0
21:01:26.068354 write(2, "\r\33K\330;test@test-VirtualBox: ~\7"..., 82) = 82
21:01:26.068517 pselect6(1, [0], NULL, NULL, NULL, {[], 8}) = ? ERESTARTNOHAND (To be restarted if no handler)
21:01:26.333576 --- SIGWINCH {si_signo=SIGWINCH, si_code=SI_USER, si_pid=1460, si_uid=1000} ---
21:01:26.333677 rt_sigreturn({mask=[]}) = -1 EINTR (Llamada al sistema interrumpida)
21:01:26.333808 ioctl(0, TIOCGWINSZ, {ws_row=20, ws_col=85, ws_xpixel=0, ws_ypixel=0}) = 0
21:01:26.334101 write(2, "\r\33K\330;test@test-VirtualBox: ~\7"..., 82) = 82
21:01:26.334276 pselect6(1, [0], NULL, NULL, NULL, {[], 8}) = ? ERESTARTNOHAND (To be restarted if no handler)
21:01:26.647874 --- SIGWINCH {si_signo=SIGWINCH, si_code=SI_USER, si_pid=1460, si_uid=1000} ---
21:01:26.647940 rt_sigreturn({mask=[]}) = -1 EINTR (Llamada al sistema interrumpida)
21:01:26.648061 ioctl(0, TIOCGWINSZ, {ws_row=18, ws_col=82, ws_xpixel=0, ws_ypixel=0}) = 0
21:01:26.648157 write(2, "\r\33K\330;test@test-VirtualBox: ~\7"..., 82) = 82
21:01:26.648281 pselect6(1, [0], NULL, NULL, NULL, {[], 8}) = ? ERESTARTNOHAND (To be restarted if no handler)
21:01:26.648731 --- SIGWINCH {si_signo=SIGWINCH, si_code=SI_USER, si_pid=1460, si_uid=1000} ---
21:01:26.648777 rt_sigreturn({mask=[]}) = -1 EINTR (Llamada al sistema interrumpida)
21:01:26.648844 ioctl(0, TIOCGWINSZ, {ws_row=19, ws_col=85, ws_xpixel=0, ws_ypixel=0}) = 0
21:01:26.648918 write(2, "\r\33K\330;test@test-VirtualBox: ~\7"..., 82) = 82
21:01:26.648989 pselect6(1, [0], NULL, NULL, NULL, {[], 8}) = ? ERESTARTNOHAND (To be restarted if no handler)
21:01:26.960521 --- SIGWINCH {si_signo=SIGWINCH, si_code=SI_USER, si_pid=1460, si_uid=1000} ---
21:01:26.960644 rt_sigreturn({mask=[]}) = -1 EINTR (Llamada al sistema interrumpida)
21:01:26.960928 ioctl(0, TIOCGWINSZ, {ws_row=18, ws_col=85, ws_xpixel=0, ws_ypixel=0}) = 0
21:01:26.961082 write(2, "\r\33K\330;test@test-VirtualBox: ~\7"..., 82) = 82
21:01:26.961248 pselect6(1, [0], NULL, NULL, NULL, {[], 8}) = ? ERESTARTNOHAND (To be restarted if no handler)
21:01:27.195750 --- SIGWINCH {si_signo=SIGWINCH, si_code=SI_USER, si_pid=1460, si_uid=1000} ---
21:01:27.195806 rt_sigreturn({mask=[]}) = -1 EINTR (Llamada al sistema interrumpida)
21:01:27.195886 ioctl(0, TIOCGWINSZ, {ws_row=17, ws_col=85, ws_xpixel=0, ws_ypixel=0}) = 0
21:01:27.195964 write(2, "\r\33K\330;test@test-VirtualBox: ~\7"..., 82) = 82
21:01:27.196030 pselect6(1, [0], NULL, NULL, NULL, {[], 8}) = ? ERESTARTNOHAND (To be restarted if no handler)
21:01:27.533598 --- SIGWINCH {si_signo=SIGWINCH, si_code=SI_USER, si_pid=1460, si_uid=1000} ---
21:01:27.533722 rt_sigreturn({mask=[]}) = -1 EINTR (Llamada al sistema interrumpida)
21:01:27.533870 ioctl(0, TIOCGWINSZ, {ws_row=16, ws_col=85, ws_xpixel=0, ws_ypixel=0}) = 0
21:01:27.534025 write(2, "\r\33K\330;test@test-VirtualBox: ~\7"..., 82) = 82
21:01:27.534167 pselect6(1, [0], NULL, NULL, NULL, {[], 8}) = ? ERESTARTNOHAND (To be restarted if no handler)


====================================
ERROR SHOWS AT THIS POINT
====================================


21:01:27.719245 --- SIGWINCH {si_signo=SIGWINCH, si_code=SI_USER, si_pid=1460, si_uid=1000} ---
21:01:27.719345 rt_sigreturn({mask=[]}) = -1 EINTR (Llamada al sistema interrumpida)
21:01:27.719584 ioctl(0, TIOCGWINSZ, {ws_row=15, ws_col=85, ws_xpixel=0, ws_ypixel=0}) = 0
21:01:27.719733 write(2, "\r\33K\330;test@test-VirtualBox: ~\7"..., 82) = 82
21:01:27.719858 pselect6(1, [0], NULL, NULL, NULL, {[], 8}) = 1 (in [0])
21:01:28.128019 read(0, 0x7ffce7ed958f, 1) = -1 EIO (Error de entrada/salida)
21:01:28.128066 ioctl(0, TCGETS, {B38400 opost isig -icanon -echo ...}) = 0
21:01:28.128094 ioctl(0, SNDCTL_TMR_STOP or TCSETSW, {B38400 opost isig icanon echo ...}) = 0
21:01:28.128116 ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0
21:01:28.128138 rt_sigaction(SIGINT, {sa_handler=0x55d4bff0d9a0, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f5d213e3470}, {sa_handler=0x55d4bff63590, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f5d213e3470}, 8) = 0
21:01:28.128276 rt_sigaction(SIGTERM, {sa_handler=0x55d4bff0d470, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f5d213e3470}, {sa_handler=0x55d4bff63590, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f5d213e3470}, 8) = 0
21:01:28.128319 rt_sigaction(SIGHUP, {sa_handler=0x55d4bff0dd60, sa_mask=HUP INT ILL TRAP ABRT BUS FPE USR1 SEGV USR2 PIPE ALRM TERM XCPU XFSZ VTALRM SYS, sa_flags=SA_RESTORER, sa_restorer=0x7f5d213e3470}, {sa_handler=0x55d4bff63590, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f5d213e3470}, 8) = 0
21:01:28.128382 rt_sigaction(SIGALRM, {sa_handler=0x55d4bff0dd60, sa_mask=HUP INT ILL TRAP ABRT BUS FPE USR1 SEGV USR2 PIPE ALRM TERM XCPU XFSZ VTALRM SYS, sa_flags=SA_RESTORER, sa_restorer=0x7f5d213e3470}, {sa_handler=0x55d4bff63590, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f5d213e3470}, 8) = 0
21:01:28.128440 rt_sigaction(SIGWINCH, {sa_handler=0x55d4bff0d460, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f5d213e3470}, {sa_handler=0x55d4bff629f0, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f5d213e3470}, 8) = 0
21:01:28.128495 rt_sigaction(SIGINT, {sa_handler=0x55d4bff0d9a0, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f5d213e3470}, {sa_handler=0x55d4bff0d9a0, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f5d213e3470}, 8) = 0
21:01:28.128560 openat(AT_FDCWD, "/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 3
21:01:28.128755 fstat(3, {st_mode=S_IFREG|0644, st_size=2995, ...}) = 0
21:01:28.128834 read(3, "# Locale name alias data base.\n#"..., 4096) = 2995
21:01:28.128925 read(3, "", 4096)       = 0
21:01:28.128975 close(3)                = 0
21:01:28.129029 openat(AT_FDCWD, "/usr/share/locale/es_MX/LC_MESSAGES/bash.mo", O_RDONLY) = -1 ENOENT (No existe el archivo o el directorio)
21:01:28.129088 openat(AT_FDCWD, "/usr/share/locale/es/LC_MESSAGES/bash.mo", O_RDONLY) = -1 ENOENT (No existe el archivo o el directorio)
21:01:28.129140 openat(AT_FDCWD, "/usr/share/locale-langpack/es_MX/LC_MESSAGES/bash.mo", O_RDONLY) = -1 ENOENT (No existe el archivo o el directorio)
21:01:28.129195 openat(AT_FDCWD, "/usr/share/locale-langpack/es/LC_MESSAGES/bash.mo", O_RDONLY) = 3
21:01:28.129248 fstat(3, {st_mode=S_IFREG|0644, st_size=157610, ...}) = 0
21:01:28.129294 mmap(NULL, 157610, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f5d203c5000
21:01:28.129349 close(3)                = 0
21:01:28.129392 write(2, "logout\n", 7) = 7
21:01:28.129451 openat(AT_FDCWD, "/home/test/.bash_logout", O_RDONLY) = 3
21:01:28.129518 fstat(3, {st_mode=S_IFREG|0644, st_size=220, ...}) = 0
21:01:28.129570 read(3, "# ~/.bash_logout: executed by ba"..., 220) = 220
21:01:28.133518 --- SIGHUP {si_signo=SIGHUP, si_code=SI_KERNEL} ---
21:01:28.133542 --- SIGCONT {si_signo=SIGCONT, si_code=SI_KERNEL} ---
21:01:28.133556 rt_sigreturn({mask=[]}) = 220
21:01:28.133581 close(3)                = 0
21:01:28.133611 rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
21:01:28.133651 rt_sigprocmask(SIG_BLOCK, CHLD TSTP TTIN TTOU, [], 8) = 0
21:01:28.133674 ioctl(255, TIOCSPGRP, 1467) = -1 ENOTTY (Función ioctl no apropiada para el dispositivo)
21:01:28.133702 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
21:01:28.133723 setpgid(0, 1467)        = -1 EPERM (Operación no permitida)
21:01:28.133750 rt_sigaction(SIGHUP, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f5d213e3470}, {sa_handler=0x55d4bff0dd60, sa_mask=HUP INT ILL TRAP ABRT BUS FPE USR1 SEGV USR2 PIPE ALRM TERM XCPU XFSZ VTALRM SYS, sa_flags=SA_RESTORER, sa_restorer=0x7f5d213e3470}, 8) = 0
21:01:28.133775 getpid()                = 1467
21:01:28.133793 kill(1467, SIGHUP)      = 0
21:01:28.133813 --- SIGHUP {si_signo=SIGHUP, si_code=SI_USER, si_pid=1467, si_uid=1000} ---
21:01:28.134085 +++ killed by SIGHUP +++

I have run perl -d:Trace, but is extremly long and it could not see any different information, the application runs the WINCH subroutine, until it suddenly receives the hup signal.

Thanks for your help

Replies are listed 'Best First'.
Re: application crash during WINCH Signal
by dave_the_m (Monsignor) on Nov 28, 2019 at 08:43 UTC
    Without looking in detail, what is obvious is that your perl process sends a hang-up signal to itself (SIGHUP). There is no handler set up for this signal, so the process is killed. So the problem is either that the process shouldn't be sending itself a HUP signal, or that you need to handle it.

    Dave.

      Hi Dave,

      Thanks for your answer,the connection code is 4000+ lines long, the HUP handler signal is the there a few lines below.

      Still haven't found any place where the same application could be sending itself the hup, signal, but will keep looking.

      But what I do not get is, why would happen in one desktop environment and not others.

      This is a larger section of the code, the HUP Signal it is handled, tell me if I should post all of it. Or this is the link to the complete code in that section pac_conn
      The other pace that has interaction with pac_conn is PACTerminal.pm

      There are some hup signals sent from PACTerminal.pm, I'll comment them to see if there is any change, but It doesn't seam to be related.

      $SIG{'WINCH'} = sub { if (!$CONNECTED) { return 1; } while (! $EXP -> slave) { select(undef, undef, undef, 0.25); }; $EXP -> slave -> clone_winsize_from(\*STDIN); kill WINCH => $EXP -> pid if $EXP -> pid; }; $SIG{'INT'} = undef; $SIG{'HUP'} = sub { # Avoid more interruptions local $SIG{'WINCH'} = undef; my $chain_uuid = ''; my $CHAIN_CFG; if ($INT) { return 1; } $INT = 1; # First, read the file with the configuration to use my $rin = ''; vec($rin, fileno($SOCKET), 1) = 1; select($rin, undef, undef, 2) or return 1; sysread($SOCKET, $chain_uuid, 1024); $chain_uuid =~ s/^!!_PAC_CHAIN_\[(.+)\]!!$/$1/g; if (! $chain_uuid) { $INT = 0; return 1; } # Second, retrieve the 'serialized' configuration to be used $rin = ''; vec($rin, fileno($SOCKET), 1) = 1; select($rin, undef, undef, 2) or return 1; eval {$CHAIN_CFG = fd_retrieve($SOCKET);}; if ($@) { $INT = 0; return 1; } # Prepare some progressbar data my $chain_name = $$CHAIN_CFG{'environments'}{$chain_uuid}{'name'}; my $exp_partial = 0; my $exp_total = 0; foreach my $exp (@{$$CHAIN_CFG{'environments'}{$chain_uuid}{'expec +t'}}) { if ($$exp{'active'} // 0) { ++$exp_total; } } if (! $exp_total) { $INT = 0; return 1; } ctrl("CHAIN:$chain_name:$chain_uuid:$exp_partial:$exp_total"); my $TIMEOUT_CMD = $$CHAIN_CFG{'defaults'}{'timeout command'} || un +def; if ($$CHAIN_CFG{'environments'}{$chain_uuid}{'terminal options'}{' +use personal settings'}) { $TIMEOUT_CMD = $$CHAIN_CFG{'environments'}{$chain_uuid}{'termi +nal options'}{'timeout command'} || undef; } my $end = 0; my $avoid_first_expectation = 1; $EXP -> restart_timeout_upon_receive(1); for(my $i = 0; $i < scalar(@{$$CHAIN_CFG{'environments'}{$chain_uu +id}{'expect'}}); $i++) { my $hash = $$CHAIN_CFG{'environments'}{$chain_uuid}{'expect'}[ +$i]; my $pattern = $$hash{'expect'} // ''; my $command = $$hash{'send'} // ''; my $hide = $$hash{'hidden'} // 0; my $active = $$hash{'active'} // 0; my $return = $$hash{'return'} // 1; my $on_match = $$hash{'on_match'} // -1; my $on_fail = $$hash{'on_fail'} // -1; my $time_out = $$hash{'time_out'} // -1; if ($active) { next; } my $jump = 0; if ($time_out >= 0) { $TIMEOUT_CMD = $time_out; } $pattern = subst($pattern); ctrl("CHAIN:$chain_name:WAITING($pattern):" . ($exp_partial++) + . ":$exp_total"); # Wait for pattern prompt before continue... $EXP -> expect($TIMEOUT_CMD, [timeout => sub { if ($on_fail == -1) { ctrl("CLOSE:TIMEOUT:$TIMEOUT_CMD seconds expecting + pattern '$pattern'!!"); $CONNECTED = 0; $EXP -> hard_close; } elsif ($on_fail == -2) { ctrl("CHAIN:EXPECT:ON_FAIL:timeout expecting '$pat +tern'. Finishing Expect"); $CONNECTED = 1; $end = 1; } else { ctrl("CHAIN:EXPECT:ON_FAIL:timeout expecting '$pat +tern'. Jumping to '$on_fail'"); $i = --$on_fail; $jump = 1; } }], [eof => sub { $CONNECTED = 0; ctrl("CLOSE:Connection ended by remote peer!! " . $EXP + -> set_accum()); $EXP -> hard_close(); }], # Found Host-Key verification string [$HOSTCHANGE_PROMPT, sub { my $match = $EXP -> match; $match =~ /$HOSTCHANGE_PROMPT/go; my ($yes, $no) = ($1, $2); if ($ACCEPT_KEY) { send_slow($EXP, $yes . (($METHOD =~ /^.*3270.*$/) +|| ($METHOD eq 'IBM 3270/5250')) ? "\r\f" : "\n"); ctrl("EXPECT:HOSTKEY:accepted by configuration (se +nt '$yes')"); exp_continue; } else { send_slow($EXP, $no . (($METHOD =~ /^.*3270.*$/) | +| ($METHOD eq 'IBM 3270/5250')) ? "\r\f" : "\n"); $CONNECTED = 0; $EXP -> hard_close(); ctrl("CLOSE:EXPECT:HOSTKEY:rejected by configurati +on (sent '$no')"); } }], [($avoid_first_expectation) ? '' : $pattern, sub { if ($on_match == -1) { $jump = 0; } elsif ($on_match == -2) { $end = 1; $CONNECTED = 1; ctrl("CHAIN:EXPECT:ON_MATCH:found pattern '$patter +n'. Stopping by config"); } else { ctrl("CHAIN:EXPECT:ON_MATCH:found pattern '$patter +n'. Jumping to '$on_match'"); $avoid_first_expectation = 1; $i = --$on_match; } }] ); # EXPECT CLOSE if ($end) { last; } if ($jump) { next; } $avoid_first_expectation = 0; if (!$CONNECTED) { last; } $command = subst($command); # ... and launch command if ($hide) { ctrl("CHAIN:$chain_name:SENDING(<<HIDDEN STRING>>):$exp_pa +rtial:$exp_total"); $EXP -> log_stdout(0); } else { my $cmd_str = $command; $cmd_str =~ s/\n$//go; ctrl("CHAIN:$chain_name:SENDING:$cmd_str" . ($return ? '\n +' : '') . ":$exp_partial:$exp_total"); } send_slow($EXP, $command . ($return ? (($METHOD =~ /^.*3270.*$ +/) || ($METHOD eq 'IBM 3270/5250') ? "\r\f" : "\n") : '')); } $EXP -> log_stdout(0); $EXP -> restart_timeout_upon_receive(0); if ($$CHAIN_CFG{'tmp'}{'set title'}) { ctrl("TITLE:$$CHAIN_CFG{'tmp'}{'title'}"); } ctrl("CONNECTED"); $INT = 0; return 1; };
Re: application crash during WINCH Signal
by bliako (Monsignor) on Nov 28, 2019 at 09:58 UTC

    kill

    SIGNAL may be either a signal name (a string) or a signal number. A signal name may start with a SIG prefix, thus FOO and SIGFOO refer to the same signal. The string form of SIGNAL is recommended for portability because the same signal may have different numbers in different operating systems.

    Is it worth using the name of the signal (as a string) throughout your code?

    p.s. there was a question here some months ago about how resizing a terminal would crash some perl application. But I can't seem to find it.

    EDIT: the link is this: Re: need help golfing down/making a backtrace for panic: free from wrong pool, … during global destruction. , and refers to a perl application crashing when terminal hosting it resizes.

      Hi bliako

      Sorry if I could not follow you comment, but the quote on the signal reference you did says that it is recommended to use the STRING, and not the numbers.

      We are recovering this application that it was unfortunately abandoned, so we are still getting familiar with the code.

      I did read the kill reference some time ago and I did not see any reason why change it.


      I changed the kill line to
      kill 'WINCH' => $EXP -> pid if $EXP -> pid;

      It made not difference

        I was merely saying that using a signal name, e.g. kill "WINCH" => $pid is the most straight-forward way to specify a signal. I am not sure if using constant WINCH (like your code is doing) is as safe. That's why I mentioned it. At least you don't use numbers e.g. kill 10 => $pid which is obviously wrong non-portable.

        Your handler propagates the WINCH signal further down all the way to the shell. In your handler you can at least monitor the pids sent the WINCH and see which one crashes. Is it perl? Is it bash? Is it ssh?

        I have put the link about a WINCH-related crash in the post above.

      Hi bliako

      Read the post, did not understood it, I know that resizing causes the problem.

Re: application crash during WINCH Signal
by marioroy (Prior) on Nov 29, 2019 at 21:32 UTC

    Hi hanspr,

    I tried a fresh Xubuntu install and experience WINCH not working in Xubuntu 18.04.3 and 19.10. In fact the WINCH handler never stops once reaching past the end of the terminal screen (i.e. runs repeatedly even though not resizing the application window).

    Fortunately, there's a solution. On the login screen, choose "Xfce Session". The Gtk3 asbru-cm application works in Xubuntu 18.04.3 and 19.10 as expected. Possibly, something to do with the "Xubuntu Session".

    Update: Fix for the Xubuntu Session

    The fix for the "Xubuntu Session" is unsetting the "GTK_OVERLAY_SCROLLING" environment variable not present inside the "Xfce Session". A good place is at the top of the script in /opt/asbru/asbru-cm (well, before loading any Gtk3 related modules).

    BEGIN { # Fix for WINCH handling using Gtk3 on Xubuntu 18.04.3 and 19.10 delete $ENV{'GTK_OVERLAY_SCROLLING'}; } use utf8; binmode STDOUT,':utf8'; binmode STDERR,':utf8'; ...

    Regards, Mario

      Thanks a lot Mario, I saw your message on github, thanks again here too.

      Your solutions fixes the issue for good.

        Great to hear hanspr. I was curious and took a look. No changes were necessary to the WINCH handler. Removing an environment variable resolves the issue from what I can tell.

Re: application crash during WINCH Signal
by hanspr (Sexton) on Nov 29, 2019 at 03:11 UTC

    Another bit of information:

    I ran strace on both pids, pac_conn that spawns a bash session, and the bash session

    1779 pts/0 Ss 0:00 \_ bash 2038 pts/0 Sl+ 0:03 | \_ perl asbru-cm 2227 pts/2 Ssl+ 0:00 | \_ perl /home/test/asbru-cm/lib/pa +c_conn /home/test/.config/pac/tmp/pac_PID{2038}_n3freeze __PAC_SHELL_ +_ 2234 pts/3 Ss+ 0:00 | \_ /bin/bash -login 1793 pts/1 Ss 0:00 \_ bash 2244 pts/1 R+ 0:00 \_ ps xaf

    pac_conn propagates the signal to the bash session. Eventually the bash session sends itself a HUP signal, it kills it self and the on the next SIGWINCH pac_conn access a non existent pid and dies with a core dump.

    The problem is happening outside the application on the bash shell.

    I do not think this is a perl problem, where could be a good place to follow up this, any suggestions?

Re: application crash during WINCH Signal
by hanspr (Sexton) on Nov 29, 2019 at 20:33 UTC

    For documentation porpoises and to help a future troubled soul with a similar ugly bug. This is the walk around I used to handle the problem.

    I still think there is something buggy in xubuntu, that causes the WINCH signals to pile up if they come too quick one after another, so I had to introduce a mechanism to process one by one and give it enough time to each process to finish

    #$SIG{'WINCH'} = sub { # if (!$CONNECTED) { # return 1; # } # while (!$EXP->slave) { # select(undef, undef, undef, 0.1); # }; # $EXP->slave->clone_winsize_from(\*STDIN); # kill 'WINCH'=>$EXP->pid if $EXP->pid; #}; sub winch { $SIG{'WINCH'} = undef; select(undef, undef, undef, 0.2); while (!$EXP->slave) { select(undef, undef, undef, 0.1); }; $EXP->slave->clone_winsize_from(\*STDIN); kill 'WINCH'=>$EXP->pid if $EXP->pid; $SIG{'WINCH'} = \&winch; return 1; } $SIG{'WINCH'} = \&winch;
Re: application crash during WINCH Signal
by hanspr (Sexton) on Nov 28, 2019 at 19:24 UTC

    I hope this information additional information helps to solve the problem:

    I commented the code like this.
    $SIG{'WINCH'} = sub { # if (!$CONNECTED) { # return 1; # } # while (! $EXP -> slave) { # select(undef, undef, undef, 0.25); # }; # $EXP -> slave -> clone_winsize_from(\*STDIN); kill WINCH => $EXP -> pid if $EXP -> pid; };

    Then, followed the next steps

    • Open e local bash terminal
    • type : trap 'stty size' winch <enter>
    • Type enter, enter, enter, ... until I arrive to the last line
    • Then the terminal fills with:
    test@test-VirtualBox:~$trap 'stty size' winch test@test-VirtualBox:~$ 24 85 test@test-VirtualBox:~$ 24 85 test@test-VirtualBox:~$ 24 85 test@test-VirtualBox:~$ 24 85 test@test-VirtualBox:~$ 24 85 test@test-VirtualBox:~$ 24 85 test@test-VirtualBox:~$ 24 85 test@test-VirtualBox:~$ 24 85 test@test-VirtualBox:~$ 24 85 test@test-VirtualBox:~$ 24 85 test@test-VirtualBox:~$ 24 85 test@test-VirtualBox:~$ 24 85 test@test-VirtualBox:~$ 24 85 test@test-VirtualBox:~$ 24 85 test@test-VirtualBox:~$ 24 85 test@test-VirtualBox:~$ 24 85 test@test-VirtualBox:~$ 24 85 test@test-VirtualBox:~$ 24 85 test@test-VirtualBox:~$ 24 85 <-= DISCONNECTED (PRESS <ENTER> TO RECONNECT) (Thu Nov 28 13:14:40 20 +19)

    And then stops

    Looks like it enters into an infinite loop. This behaviour is not seen in any other desktop, environment.

    In other desktop environments you see:

    hans@hans-desktop:~$ trap 'stty size' winch hans@hans-desktop:~$ hans@hans-desktop:~$ hans@hans-desktop:~$ hans@hans-desktop:~$ hans@hans-desktop:~$ hans@hans-desktop:~$

    The winch signal is never called when you arrive to the end, only on a window resize.

    It would be help full for me to see if I understand the code correctly

    $SIG{'WINCH'} = sub { kill WINCH => $EXP -> pid if $EXP -> pid; };

    The kill line, what it does is stop the WINCH event from being called again be the same event, right?

    Could it be that in xubuntu is not being sent and then the signal keeps arriving until there is a stack overflow or something similar?

      The kill line, what it does is stop the WINCH event from being called again be the same event, right?

      kill WINCH => $EXP -> pid if $EXP -> pid; sends the WINCH signal to the process with pid $EXP->pid. Where $EXP is an Expect object (i guess). The bottom line is that kill is sending a specified signal to a specified process. It does not stop or block a signal.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11109349]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (2)
As of 2024-04-25 20:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found