rpmohn / a4

dynamic terminal manager and multiplexer
https://a4term.com
MIT License
33 stars 4 forks source link

segfault #1

Closed MaxGyver83 closed 1 year ago

MaxGyver83 commented 1 year ago

Hi Ross,

I just tried a4 (after seeing its announcement on the suckless mailing list). After playing around with it for a minute or two, I get a segmentation fault. I can't reproduce it reliably with a certain sequence of the key strokes, but it happened several times after using these commands (in random order):

(I think Ctrl-g . and Ctrl-g Enter were the last before the crash.)

Maybe these coredumps help:

Update (with a debug build):

Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x000055f78034247b in vts_sb_popline (cols=232, cells=0x55f781fe9380, user=0x55f781ff1dc0) at /home/max/repos/a4/vt.c:167
167                             .fg = tframe->cs->fg,

Versions

rpmohn commented 1 year ago

The git mirror of libtickit is not up-to-date. Not sure if that'll fix it, but it's a good place to start. If you can't grab the bzr repo directly, I've attached a tarball of rev 810 that you can use.

bzr branch https://bazaar.leonerd.org.uk/c/libvterm/

Please let me know, thanks! -Ross libtickit_r810.tar.gz

MaxGyver83 commented 1 year ago

Thank you. After building and installing libtickit from your tarball, I got the same segfault.

So to be sure, I have installed bzr and cloned the repository and installed again. Same error:

coredump3.txt

MaxGyver83 commented 1 year ago

Maybe this helps: I have commented in all occurrences of DEBUG_LOGF in vts_sb_popline and logged the "Uvp" flag:

tickit.log

rpmohn commented 1 year ago

Thanks, here are some questions that might help me:

MaxGyver83 commented 1 year ago
$ ldd /usr/local/bin/a4
        linux-vdso.so.1 (0x00007ffc37187000)
        libtickit.so.3 => /usr/local/lib/libtickit.so.3 (0x00007feb2a123000)
        libvterm.so.0 => /usr/local/lib/libvterm.so.0 (0x00007feb2a10b000)
        libc.so.6 => /usr/lib/libc.so.6 (0x00007feb29f24000)
        libunibilium.so.4 => /usr/lib/libunibilium.so.4 (0x00007feb29f0f000)
        libtermkey.so.1 => /usr/lib/libtermkey.so.1 (0x00007feb29f03000)
        /lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2 (0x00007feb2a195000)

I use Arch Linux.

I couldn't reproduce this with xterm or in a console. Only with st, both my custom build and a clean build of the latest commit (e5e9598).

MaxGyver83 commented 1 year ago

And to be more specific about the segfault I get:

Core was generated by `a4/a4'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00005589fa60753a in vts_sb_popline (cols=148, cells=0x5589fad45ac0, user=0x5589facabaf0) at /home/max/repos/a4/vt.c:167
167                             .fg = tframe->cs->fg,
>>> p tframe->cs
$1 = (ColorScheme *) 0x0
>>>

tframe->cs is a null pointer. Maybe you have an idea what could have caused this.

rpmohn commented 1 year ago
  1. Can you confirm that you're only using the default a4.ini file? If not, please post what you're using.
  2. What shell are you using?
  3. Do your terminal windows in a4 have titlebar text, or is it blank? If you're not sure, please post a screenshot of what it looks like just before the crash. I suspect this is the problem and I can send you a patch to test.
MaxGyver83 commented 1 year ago
  1. Yes. (No custom configuration.)
  2. The default shell is bash. (And it seems to make no difference if I start a4 from bash or fish.)
  3. Indeed, the titlebar is blank (apart from [#1]) when I run a4 in st.

Screenshot: 2023-01-06 17 04 08 1010x705 Region (top: st, bottom: xterm)

rpmohn commented 1 year ago

Please apply and test this one line patch. If that resolves the segfault, as I suspect it will, then I'll make a couple more similar updates to make the whole thing more robust. Thanks!

patch <default_cs.txt

default_cs.txt

MaxGyver83 commented 1 year ago

Thank you. No crashes so far! tframe->cs is not NULL anymore (as expected :-) ). But the titlebars are still blank.

rpmohn commented 1 year ago

Titlebar text is typically controlled in bash by setting PROMPT_COMMAND in your .bashrc file, and then you can make color rules in a4.ini to match the text and change the color scheme of individual terminal windows. Here's the standard example, and you can change the titlebar text in other ways as well for additional control.

PROMPT_COMMAND='echo -ne "\e]0;$USER@$HOSTNAME:${PWD/$HOME/\~}\a"'
rpmohn commented 1 year ago

Here's a fun example screenshot showing an extreme use of multiple terminal color schemes: image

rpmohn commented 1 year ago

Pushed 8036fd9 to resolve this. Thanks for your help!

rpmohn commented 1 year ago

Actually, that patch is not good as it inhibits the initial colorscheme from being applied. This updated one line patch will both set and apply the initial default colors. Please let me know if you're able to validate, thanks!

patch < applydefaultcs.txt

applydefaultcs.txt

MaxGyver83 commented 1 year ago

I have tested it and it works as expected! Thank you.

rpmohn commented 1 year ago

Reclosing with improved fix bce5e14.