Ticket #3121 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

Subshell/Command line prompt is empty/missing

Reported by: z0rc Owned by:
Priority: major Milestone: 4.8.12
Component: mc-core Version: 4.8.11
Keywords: subshell Cc: egmont@…
Blocked By: Blocking:
Branch state: no branch Votes for changeset:

Description

See attached screenshot. The issue persist with TERM=(xterm|screen).*. Tested with konsole and xterm both on current Debian Sid, Ubuntu 12.04 and Ubuntu 13.10. Tested with bash and zsh. The issue doesn't exists with 'linux' terminal (without xorg, plain console at Ctrl+Alt+F1)

mc -V
GNU Midnight Commander 4.8.11
Built with GLib 2.36.4
Using the S-Lang library with terminfo database
With builtin Editor
With subshell support as default
With support for background operations
With mouse support on xterm and Linux console
With support for X11 events
With internationalization support
With multiple codepages support
Virtual File Systems: cpiofs, tarfs, sfs, extfs, ext2undelfs, ftpfs, sftpfs, fish
Data types: char: 8; int: 32; long: 64; void *: 64; size_t: 64; off_t: 64;

I bisected issue to:
e35f044ccdd41922f925c99e6d50930ea8c7c47e is the first bad commit
commit e35f044ccdd41922f925c99e6d50930ea8c7c47e
Author: Andrew Borodin <aborodin@…>
Date: Tue Jan 1 19:53:11 2013 +0400

(subshell_prompt): changed to GString.


(read_subshell_prompt): refactoring to ret rid of low-level memory reallocation.


Signed-off-by: Andrew Borodin <aborodin@…>

Attachments

41.png (128.6 KB) - added by z0rc 3 years ago.

Change History

Changed 3 years ago by z0rc

comment:1 Changed 3 years ago by andrew_b

Sorry, but I'm unable reproduce this bug.

comment:2 Changed 3 years ago by andrew_b

  • Cc aborodin@… removed
  • Version changed from master to 4.8.11
  • Component changed from mc-tty to mc-core

comment:3 Changed 3 years ago by andrew_b

Ok, let step by step.

Is it happened immediately after start or after any actions?
What is your $PS1?
Does your $PS1 depend on your $TERM value or any other condition?

comment:4 Changed 3 years ago by z0rc

OK, I've made additional tests. I was wrong about bash, it happens only with zsh. $PS1 is irrelevant as see this behavior with empty zshrc. Though it happens, but not so often. Usually this happens with mc start and the prompt may appear on dir change ...or may not. From my perspective it's more like race condition somewhere and the heavier my zshrc, the often it happens.

Just in case you can check my zshrc at https://github.com/z0rc/dotfiles/blob/master/zshrc.

I'll try to dig into gdb later this week.

comment:5 follow-up: ↓ 7 Changed 3 years ago by egmont

I can't reproduce, just looking at the code, but line 1022: g_string_set_size (subshell_prompt, 0) is fishy, it's inside the while(select(...)) loop that takes care of assembling multiple short reads, but I guess it should be before that loop.

comment:6 Changed 3 years ago by egmont

  • Cc egmont@… added

comment:7 in reply to: ↑ 5 Changed 3 years ago by andrew_b

Replying to egmont:

I can't reproduce, just looking at the code, but line 1022: g_string_set_size (subshell_prompt, 0) is fishy, it's inside the while(select(...)) loop that takes care of assembling multiple short reads, but I guess it should be before that loop.

This was fixed in #3001.

comment:8 follow-up: ↓ 9 Changed 3 years ago by z0rc

I'm continuing my investigation. Current situation:

Breakpoint 3, setup_cmdline () at layout.c:816
816     {
(gdb) bt full
#0  setup_cmdline () at layout.c:816
        prompt_len = <optimized out>
        y = <optimized out>
        tmp_prompt = <optimized out>
#1  0x0000000000436752 in do_load_prompt () at layout.c:1328
        ret = <optimized out>
#2  0x0000000000436779 in load_prompt (fd=<optimized out>, unused=<optimized out>) at layout.c:1350
No locals.
#3  0x00000000004334b0 in check_selects (select_set=select_set@entry=0x7fffffffcf40) at key.c:592
        p = 0x7ff1a0
#4  0x0000000000434a78 in check_selects (select_set=0x7fffffffcf40) at key.c:559
No locals.
#5  tty_get_event (event=event@entry=0x7fffffffd000, redo_event=0, block=block@entry=1) at key.c:2069
        nfd = <optimized out>
        select_set = {fds_bits = {0 <repeats 16 times>}}
        c = <optimized out>
        flag = 1
        time_out = {tv_sec = 8375264, tv_usec = 0}
        time_addr = <optimized out>
        dirty = 1
#6  0x000000000041a417 in frontend_dlg_run (h=0x7fb640) at dialog.c:567
        d_key = <optimized out>
        event = {buttons = 0, x = -1, y = 13, type = (GPM_UP | GPM_DOUBLE)}
#7  dlg_run (h=0x7fb640) at dialog.c:1256
No locals.
#8  0x000000000043bdf5 in create_panels_and_run_mc () at midnight.c:959
No locals.
#9  do_nc () at midnight.c:1774
        ret = <optimized out>
        midnight_colors = {1, 1, 1, 1, 1}
#10 0x000000000040a065 in main (argc=1, argv=0x7fffffffd288) at main.c:400
        error = 0x0
        config_migrated = 0
        config_migrate_msg = 0x7ffff7ffe5c0 " \345\377\367\377\177"
        exit_code = 1
(gdb) print subshell_prompt->str
$23 = (gchar *) 0x823c60 "\033[0m\033[27m\033[24m\033[J[mc][\033[01;33mkoumakan\033[00m][\033[01;32m~/rebuild\033[00m]% \033[K"
(gdb) cont
Continuing.

Breakpoint 3, setup_cmdline () at layout.c:816
816     {
(gdb) bt full
#0  setup_cmdline () at layout.c:816
        prompt_len = <optimized out>
        y = <optimized out>
        tmp_prompt = <optimized out>
#1  0x0000000000436752 in do_load_prompt () at layout.c:1328
        ret = <optimized out>
#2  0x0000000000436779 in load_prompt (fd=<optimized out>, unused=<optimized out>) at layout.c:1350
No locals.
#3  0x00000000004334b0 in check_selects (select_set=select_set@entry=0x7fffffffcf40) at key.c:592
        p = 0x7ff1a0
#4  0x0000000000434a78 in check_selects (select_set=0x7fffffffcf40) at key.c:559
No locals.
#5  tty_get_event (event=event@entry=0x7fffffffd000, redo_event=0, block=block@entry=1) at key.c:2069
        nfd = <optimized out>
        select_set = {fds_bits = {0 <repeats 16 times>}}
        c = <optimized out>
        flag = 1
        time_out = {tv_sec = 8375264, tv_usec = 0}
        time_addr = <optimized out>
        dirty = 1
#6  0x000000000041a417 in frontend_dlg_run (h=0x7fb640) at dialog.c:567
        d_key = <optimized out>
        event = {buttons = 0, x = -1, y = 13, type = (GPM_UP | GPM_DOUBLE)}
#7  dlg_run (h=0x7fb640) at dialog.c:1256
No locals.
#8  0x000000000043bdf5 in create_panels_and_run_mc () at midnight.c:959
No locals.
#9  do_nc () at midnight.c:1774
        ret = <optimized out>
        midnight_colors = {1, 1, 1, 1, 1}
#10 0x000000000040a065 in main (argc=1, argv=0x7fffffffd288) at main.c:400
        error = 0x0
        config_migrated = 0
        config_migrate_msg = 0x7ffff7ffe5c0 " \345\377\367\377\177"
        exit_code = 1
(gdb) print subshell_prompt->str
$24 = (gchar *) 0x802ce0 "\033[?1h\033="

This is strange as at directory change we enter setup_cmdline two times, first enter with correct prompt, second with bogus. At second break I can see the valid prompt in mc, which later gets changed to nothing. I'll continue to dig this up. If you have any hints, please share.

comment:9 in reply to: ↑ 8 Changed 3 years ago by andrew_b

I think you should check subshell_prompt in read_subshell_prompt().

comment:10 Changed 3 years ago by z0rc

Please close this as invalid. It appears my problem after all. Though it wasn't obvious to spot. Basically zsh has two prompts: left and right, mc was interpreting both of them. I had an option to set RPROMPT to be "" (empty string) if zsh is running under mc, it was working just fine. Right now I have to completely undefine RPROMPT, so mc won't interpret it.

comment:11 Changed 3 years ago by andrew_b

  • Status changed from new to closed
  • Resolution set to invalid
  • Milestone Future Releases deleted

comment:12 Changed 3 years ago by z0rc

  • Status changed from closed to reopened
  • Resolution invalid deleted
  • Milestone set to Future Releases

I spoke to soon and reopening this ticket. Sorry.

RPROMPT has nothing to do with this as it won't affect the situation, as I though initially. "\033[?1h\033=" is present always, event when RPROMPT isn't set. This looks like mark of prompt end, as they present event with empty PROMPT.

I still think this is some kind of race condition. I can catch empty prompt comes after valid when setting up just watch on subshell_prompt variable. But when I break on read_subshell_prompt the empty shell won't appear and issue won't show up. Also I cannot catch issue under strace, then mc behaves just fine.

comment:13 Changed 3 years ago by andrew_b

  • Blocked By 3125 added

comment:14 Changed 3 years ago by andrew_b

  • Blocked By 3125 removed

comment:15 Changed 3 years ago by andrew_b

  • Status changed from reopened to closed
  • Resolution set to fixed
  • Milestone changed from Future Releases to 4.8.12
Note: See TracTickets for help on using tickets.