On Fri, Feb 18, 2022 at 03:12:14PM +0100, Rhonda D'Vine wrote: > Dear Lee, > > * Lee Garrett <deb...@rocketjump.eu> [2022-02-09 18:27:38 CET]: > > Package: tetradraw > > Version: 2.0.3-9+b2 > > Followup-For: Bug #716386 > > X-Debbugs-Cc: deb...@rocketjump.eu > > > > Hi Rhonda, > > > > sorry to grave dig this bug report, but it seems that tetradraw might be > > broken > > for a couple of releases now. On bullseye it segfaults with rc 139. A few > > people > > in #debian reported the same issue, so it looks like it's 100% reproducible. > > Since I'd love to make some nice ascii art for my /etc/motd, it would be > > nice if > > you could find the time to fix it. Thanks in advance! > > You are definitely right on that. I think in one of the bugs there is > a workaround for the issue: It runs smoothly on a virtual console > instead of within a terminal in Xorg. So if that's possible, I suggest > to go that path. > > What also works is starting it with TERM=linux. This gives a hint in > what area the issue may lie. I am unfortunately not a well enough coder > to dig further into it, but those are the workarounds that I am aware > of, and might give people a hint on where to look into for fixing this.
I was looking at this and the segfault is from src/term.c, line 205. The part of the code is: for(count = 1; count < COLOR_PAIRS; count++) { init_pair(count, count % COLORS, count / COLORS); colours[count % COLORS][count / COLORS] = count; } Further debugging showed COLOR_PAIRS was 65536, so the value of count can be 65535, and COLORS is defined as 256. So, colours[count % COLORS][count / COLORS] can become colours[65535 % 256][65535 / 256] which means the max array location it can try to access of colours[0][255]. But colours is declared as colours[8][8], so its trying to access memory locations beyond what has been allocated to it. The following patch will stop the segfault but I dont know what tetradraw is supposed to do to check if it has other impact or not. --- tetradraw-2.0.3.orig/src/global.h +++ tetradraw-2.0.3/src/global.h @@ -5,7 +5,7 @@ extern coordinate td_maxx; extern coordinate td_maxy; -extern colour colours[COLOURS][COLOURS]; +extern colour colours[256][256]; extern int remote; extern int pagecnt; extern char default_highascii[20][10]; --- tetradraw-2.0.3.orig/src/tetradraw.c +++ tetradraw-2.0.3/src/tetradraw.c @@ -45,7 +45,7 @@ void load_options(); coordinate td_maxx = 0; coordinate td_maxy = 0; -colour colours[COLOURS][COLOURS]; +colour colours[256][256]; canvas *pages[9] = { NULL, NULL, --- tetradraw-2.0.3.orig/src/tetraview.c +++ tetradraw-2.0.3/src/tetraview.c @@ -41,7 +41,7 @@ coordinate td_maxx = 0; coordinate td_maxy = 0; -colour colours[COLOURS][COLOURS]; +colour colours[256][256]; int remote = 0; -- Regards Sudip