dankamongmen / notcurses

blingful character graphics/TUI library. definitely not curses.
https://nick-black.com/dankwiki/index.php/Notcurses
Other
3.57k stars 112 forks source link

metric: fix test on armhf/glibc 2.37 #2707

Closed dbungert closed 1 year ago

dbungert commented 1 year ago

In the metric test is a call to ncnmetric, which eventually calls snprintf. Along the way is a size that is much larger than the actual bufsize, but it shouldn't matter as the buffer size exceeds what we print (or at least what is expected).

In testing with glibc 2.37 on armhf on Ubuntu Lunar, I found that these metric tests can fail with some unexpected truncation of the values.

For example, in the following check,

    impericize_ncmetric(0, 1, buf, 0, 1000, '\0');
    CHECK(!strcmp("0.00", buf));

buf would actually be "0.0".

Using a more realistic buffer size produces a working result.

dankamongmen commented 1 year ago

hey there =] i saw your bug filed this morning on Launchpad. thanks a lot for looking into this.

i'm super tired right now after being awake for many hours, but this doesn't look quite right. i suspect there is a bug deeper in the code. that output ought definitely be "0.00" as i understand it....

oh, wait, reading your comment again, your patch does make it output "0.00". ok, great, good work! imma go smoke a cigarette and then come back in and merge this assuming i don't think of any other problems, real or imagined.

dankamongmen commented 1 year ago

i should probably update the notcurses_metric.3 man page to not use INT_MAX in all the examples, too.

dankamongmen commented 1 year ago

merged! thanks a bunch!