Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault when scrolling past the last tablet in reels #2717

Open
c4l1c0 opened this issue May 3, 2023 · 8 comments
Open

Segfault when scrolling past the last tablet in reels #2717

c4l1c0 opened this issue May 3, 2023 · 8 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@c4l1c0
Copy link

c4l1c0 commented May 3, 2023

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
@c4l1c0 c4l1c0 added the bug Something isn't working label May 3, 2023
@c4l1c0
Copy link
Author

c4l1c0 commented May 3, 2023

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

@dankamongmen dankamongmen self-assigned this May 3, 2023
@dankamongmen
Copy link
Owner

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!

@dankamongmen dankamongmen added this to the 3.1.0 milestone May 3, 2023
@c4l1c0
Copy link
Author

c4l1c0 commented May 4, 2023

Appreciate it, take it easy, cheers!

@c4l1c0
Copy link
Author

c4l1c0 commented May 4, 2023

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!

@dankamongmen
Copy link
Owner

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

@c4l1c0
Copy link
Author

c4l1c0 commented Jul 7, 2023

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.

@c4l1c0
Copy link
Author

c4l1c0 commented Jul 16, 2023

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.

@c4l1c0 c4l1c0 closed this as completed Jul 16, 2023
@c4l1c0
Copy link
Author

c4l1c0 commented Jul 16, 2023

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

@c4l1c0 c4l1c0 reopened this Jul 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants