dankamongmen / notcurses

blingful character graphics/TUI library. definitely not curses.

Home Page:https://nick-black.com/dankwiki/index.php/Notcurses

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Segfault when scrolling past the last tablet in reels

c4l1c0 opened this issue · comments

Please include the following data:

  • export | egrep 'LANG|LC_CTYPE|TERM'
declare -x COLORTERM="truecolor"
declare -x LANG="en_US.UTF-8"
declare -x TERM="xterm-kitty"
declare -x TERMINFO="/usr/lib/kitty/terminfo"
  • notcurses version (available from notcurses-demo i)
notcurses-demo version 3.0.9
  • terminal name + version
kitty 0.28.1 created by Kovid Goyal

Issue description

So, i'm creating a program that use reel, but when scrolling down past the last displayed tablet, i got a segfault. I tried scrolling up, it works fine, but when i scroll down again it segfaults.

To make sure it's not just my code, i tried running the reel demo, when i scroll down past the last tablet or sometimes past the last tablet displayed, the demo segfaults too. Scrolling up works fine too in the demo.

Debugger log

Here's the errors i can capture from gdb

ncreel_redraw:755:error tightening reel
malloc_consolidate(): unaligned fastbin chunk detected

Thread 1 "4cnc" received signal SIGABRT, Aborted.
__pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
44	     return INTERNAL_SYSCALL_ERROR_P (ret) ? INTERNAL_SYSCALL_ERRNO (ret) : 0;                                                                                   
(gdb) 6u6;1:3u

How to reproduce:

  1. Run the reel demo notcurses-demo r
  2. Scroll down using j or down arrow key
  3. Segfault

I just tried adding less tablets to the reels so that the tablets never reach the bottom of the reels, and scrolling works fine, both ups and downs, circular and infinite, no errors whatsoever.

I then started to add tablets one by one, until something breaks, and when one of the tablets reached the bottom of the reel (or plane?), the whole screen shifts up and i got these errors everytime i press j or down

ncplane_cursor_move_yx:732:target y 2 >= height 2
ncplane_cursor_move_yx:732:target y 2 >= height 2
ncplane_cursor_move_yx:732:target y 2 >= height 2
ncplane_cursor_move_yx:732:target y 2 >= height 2
ncplane_cursor_move_yx:732:target y 2 >= height 2
ncplane_resize_internal:834:can't keep 3@1 rows from 3                                                                                    ncreel_redraw:725:error drawing tablet

Adding one more tablet at this point and then scrolling down gives me segfault

ick, this likely affects my growlight tool if this is all valid. i'll look into it as soon as i can (probably not before this weekend, sadly). thanks for the high-quality report!

Appreciate it, take it easy, cheers!

So i just done more testing, and apparently when i remove the top and bottom borders of the tablets using tabletmask in ncreel_options struct, the segfaults completely gone.

Enabling either top, bottom, or both, triggers the segfaults when scrolling down.

I think i'm going to disable top and bottom border as a workaround for now. Thanks!

oh that's a great find! thanks a lot, that ought make things significantly easier!

Update, i was experiencing segfault sometimes with no border around the tablets. This time the tablet contains longer text inside it.

If anyone experiencing this, the workaround is by incrementing the number of lines returned by tablet callback.

Apparently, this is because i counted the content of the tablets wrong, hence i returned the wrong return value for the tablet callback. This is the cause of the segfaults. SOOOO DUMB!!

Thanks for the help, i'm closing this issue.

Wait sorry, i'm a dumbass, apparently it still happens when the tablet have top and/or bottom borders.