bugGNU Screen - Bugs: bug #25291, Screen crashes after passing...

 
 

bug #25291: Screen crashes after passing through a zmodem transfer

Submitter:  None
Submitted:  Sat 10 Jan 2009 09:33:52 PM UTC
   
 
Category:  Crash/Freeze/Infloop Severity:  3 - Normal
Priority:  * 3 - Low Status:  Fixed
Privacy:  Public Assigned to:  None
Open/Closed:  Closed Release:  4.0.3
Fixed Release:  5.0.0 Planned Release:  5.0.0
Work Required:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Wed 10 Jul 2024 02:20:40 PM UTC, comment #10: 

...to be able to test zmodem transfer correctly, we also need to attach from the first tab to the second one:


screen -rx zmodem



Alexander Naumov <anaumov>
Group administrator
Wed 10 Jul 2024 12:10:29 PM UTC, comment #9: 
Alexander Naumov <anaumov>
Group administrator
Wed 10 Jul 2024 11:39:38 AM UTC, comment #8: 

Ok, we have a patch:

% cat ~/gnu/zmodem.patch
diff --git a/src/process.c b/src/process.c
index 129e2dc..cbd33f2 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1190,7 +1190,7 @@ static void DoCommandZmodem(struct action *act)
                int i;
                for (i = 0; i < 4; i++)
                        if (!strcmp(zmodes[i], *args))
-                               return;
+                               break;
                if (i == 4 && !strcmp(*args, "on"))
                        i = 1;
                if (i == 4) {
diff --git a/src/window.c b/src/window.c
index 9f5e2d4..042d152 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1812,7 +1812,6 @@ static void zmodem_found(Window *p, int send, char *bp, size_t len)

 void zmodem_abort(Window *p, Display *d)
 {
-       Display *olddisplay = display;
        Layer *oldflayer = flayer;
        if (p) {
                if (p->w_savelayer && p->w_savelayer->l_next) {
@@ -1831,7 +1830,6 @@ void zmodem_abort(Window *p, Display *d)
                D_readev.condpos = D_readev.condneg = NULL;
                Activate(D_fore ? D_fore->w_norefresh : 0);
        }
-       display = olddisplay;
        flayer = oldflayer;
 }


Let's test it... git master branch, Kubuntu:

% cat /etc/issue
Ubuntu 22.04.4 LTS

% dpkg -s konsole | grep '^Version:'
Version: 4:21.12.3-0ubuntu1

% git branch
* master

% git pull
Enter passphrase for key '/home/alex/.ssh/id_rsa.screen':
Already up to date.

% git rev-parse HEAD
fcfa6d2da0735d27d322ff22147534ecfb4d7302

% git apply ~/gnu/zmodem.patch

% echo $?
0

% ./configure
% make
% sudo make install

% screen -v
Screen version 4.99.0 (build on 2024-07-10 13:07:15)


I have 3 tabs in Konsole. First one I'm going to use for the first screen session 'source', second for the second one 'zmodem' and last one for the "screen -ls", i.e. for some outside checks (there is no screen session there).

Start first screen session:

[3] % screen -ls
No Sockets found in /home/alex/.screen.
[1] % screen -S source
[3] % screen -ls
There is a screen on:
        13271.source    (Attached)
1 Socket in /home/alex/.screen.


Start second screen session and enable zmodem mode there.
Check file name (example test name... let's say "passwd")

[2] % screen -S zmodem
[2] C-a :zmodem pass

# I get message 'zmodem mode is pass'

[3] % screen -ls
There are screens on:
        13344.source    (Attached)
        13393.zmodem    (Attached)
2 Sockets in /home/alex/.screen.

[2] % ls -la passwd
ls: cannot access 'passwd': No such file or directory


Send some test file from the first screen session 'source' to the second one 'zmodem' by usging 'sz' command:

[1] C-a : !!! sz /etc/passwd
Sending: passwd
Bytes Sent:   2717   BPS:511578

Transfer complete
% echo $?
0


Second session. Check the file again.
Third tab: Check the state of both screen sessions:

[2] % ls -la passwd
-rw-r--r-- 1 alex alex 2717 Sep 28  2023 passwd
[3] % screen -ls
There are screens on:
        14102.source    (Attached)
        14118.zmodem    (Attached)
2 Sockets in /home/alex/.screen.


Both screens are alive. No dead sessions. No crashes. File is there...



Alexander Naumov <anaumov>
Group administrator
Mon 08 Jul 2024 12:33:34 PM UTC, comment #7: 

comment #4:

> 15 yrs later, screen still crash...


From the official[1] documentation:
Note also that this is an experimental feature.

It seems there is no expertise for zmodem.
Someone implement this feature long time ago, but didn't support it well.
I think to drop zmodem support as an official feature until we fix it...



[1] https://www.gnu.org/software/screen/manual/html_node/Zmodem.html




Alexander Naumov <anaumov>
Group administrator
Mon 08 Jul 2024 12:09:55 PM UTC, comment #6: 

git version even more worse, it cannot set zmodem mode.
see process.c:1193, should be break, not return.
and, with fixed this but still crash.


Program received signal SIGSEGV, Segmentation fault.
zmodem_parse (p=0x5636acc36770, bp=0x7ffe54f5df21 "**\030B0800000000022d\r\212d\r\212lo1.c\030@56 14641454267 100644 0 1 56\030@\030k\361F\274\067\021\033[00m$ ", len=20) at window.c:1719
1719                                            D_blocked = 0;
(gdb) bt
#0  zmodem_parse (p=0x5636acc36770,
    bp=0x7ffe54f5df21 "**\030B0800000000022d\r\212d\r\212lo1.c\030@56 14641454267 100644 0 1 56\030@\030k\361F\274\067\021\033[00m$ ", len=20) at window.c:1719
#1  0x00005636abfb7b71 in win_readev_fn (event=0x5636acc36848, data=0x5636acc36770) at window.c:1536
#2  0x00005636abfa7d22 in sched () at sched.c:200
#3  0x00005636abf5534d in main (argc=0, argv=0x7ffe54f60280) at screen.c:1102

gmsj0001 <gmsj0001>
Mon 08 Jul 2024 09:58:36 AM UTC, comment #5: 

comment #4:

>
> ubuntu 22.04 screen 4.09.00
>


Can you test git version (master branch)?


Alexander Naumov <anaumov>
Group administrator
Mon 08 Jul 2024 09:10:53 AM UTC, comment #4: 

15 yrs later, screen still crash...

ubuntu 22.04 screen 4.09.00

Program received signal SIGSEGV, Segmentation fault.
0x0000557986023a6e in zmodem_parse (len=<optimized out>, bp=<optimized out>, p=<optimized out>) at ../window.c:2177
2177    ../window.c: Directory not empty.
(gdb) bt
#0  0x0000557986023a6e in zmodem_parse (len=<optimized out>, bp=<optimized out>, p=<optimized out>) at ../window.c:2177
#1  win_readev_fn (ev=<optimized out>, data=0x557987fc2f80 "") at ../window.c:1947
#2  0x0000557986007a67 in sched () at ../sched.c:222
#3  main (ac=<optimized out>, av=<optimized out>) at ../screen.c:1486


I've debugged this. When using zmodem pass mode, a overlay page "Zmodem active" showed by InitOverlayPage, which set w_layer.l_cvlist to NULL causing global display NULL. In zmodem_abort, through ExitOverlayPage is called for restoring canvas but will take affect in next win_readev_fn call. So nearly after zmodem_abort, display is accessed and oops.

gmsj0001 <gmsj0001>
Mon 02 Feb 2009 08:46:21 PM UTC, comment #3: 

The backtrace, from screen 4.0.3:

(gdb) bt
#0  0x00049b54 in zmodem_parse (p=0xbc270,
    bp=0xffbfd910 "OO\030B0800000000022d\r\212\021W\030@\030@\030@\030@\030@\030@\030@¤\030@\030@\030B\030W\030@\030@\030LÌ\030@\030@\030@¼\030@\030@\030K\030W\030@\030@\030@\030@\030@\030@\030@À\030@\030@\030B\030W\030@\030@\030N\030Ü\030@\030@\030@Ø\030@\030@\030K\030W\030@\030@\030@\030@\030@\030@\030@Ü\030@\030@\030B\030W\030@\030@\030R\\\030@\030@\030@ô\030@\030@\030K\030W\030@\030@\030@\030@\030@\030@\030@ø\030@\030@\030B\030W\030@\030@\030V\030X\030@\030@\030A\030P\030@\030"..., len=2) at window.c:2042
#1  0x00048dd8 in win_readev_fn (ev=0xbc2c0, data=0xbc270 "") at window.c:1842
#2  0x000895b8 in sched () at sched.c:232
#3  0x00019a0c in main ()

If you want you can find the core+binary (compiled with -g) at
http://eischnee.de/screen-zmodem-crash.tgz
SPARC Solaris 10.



Arne Jansen <sensille>
Mon 26 Jan 2009 09:39:55 PM UTC, comment #2: 

Can you please post a backtrace from the original crash? The display store/restore might need to happen somewhere else etc. The backtrace might give a better understand of the issue.

Sadrul Habib Chowdhury <sadrul>
Group administrator
Thu 15 Jan 2009 10:49:56 PM UTC, comment #1: 

My opportunities to debug something like this are pretty small... would love a ready-made patch :D

Micah Cowan <micahcowan>
Sat 10 Jan 2009 09:33:52 PM UTC, original submission:  

I tried to use screen in zmodem pass mode. The sender was inside the screen using lsz.
The first problem is that screen didn't detect the end of the transfer. It seems lsz doesn't send the final 'OO' for some reason. So after the transfer I give a manual 'OO' which the screen detects.
This is the moment screen crashes. My debugging shows that when calling zmodem_abort(p,0) the (global) display variable is NULL.
I haven't been able to find out why this is the case, but as a test I saved the current display in zmodem_found and restored it before calling zmodem_abort and the crash was gone.
The only thing that was missing then was the status bar. It only reappeared a minute later with an update of the clock.

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by anaumov (Posted a comment)
  • -email is unavailable- added by gmsj0001 (Posted a comment)
  • -email is unavailable- added by sensille (Posted a comment)
  • -email is unavailable- added by sadrul (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-07-10 micahcowan Carbon-CopyRemoved 60294 -
    2024-07-10 anaumov StatusNeed Investigation Fixed
        Open/ClosedOpen Closed
        Fixed ReleaseNone 5.0.0
        Planned ReleaseLater 5.0.0
    2009-01-15 micahcowan Priority5 - Normal 3 - Low
        StatusNone Need Investigation
        PrivacyNone Public
        Planned ReleaseNone Later

    Back to the top

    Powered by Savane 3.13-b921.
    Corresponding source code