Summary: | app-misc/mc-4.8.26 crashes on save: (mcedit:40454): GLib-ERROR **: 01:59:15.500: ../glib-2.66.4/glib/gmem.c:112: failed to allocate 18446744073709551504 bytes | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Thomas Deutschmann (RETIRED) <whissi> |
Component: | Current packages | Assignee: | Sergei Trofimovich (RETIRED) <slyfox> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | polynomial-c, sam |
Priority: | Normal | Keywords: | PATCH |
Version: | unspecified | ||
Hardware: | All | ||
OS: | Linux | ||
URL: | https://midnight-commander.org/ticket/4192 | ||
Whiteboard: | |||
Package list: | Runtime testing required: | --- | |
Attachments: | mc-4.8.26-clip-768285.patch |
Description
Thomas Deutschmann (RETIRED)
2021-02-02 01:06:02 UTC
Video showing the problem: https://dev.gentoo.org/~whissi/stuff/mced-crash_bug768285.webm Is it aUSE=-slang mc? Please post `emerge --info mc`. (In reply to Thomas Deutschmann from comment #0) > > #4 0x00007fb0711045a4 in g_malloc (n_bytes=18446744073709551588) at ../glib-2.66.4/glib/gmem.c:111 > > #5 0x000056421ef63ea1 in tty_colorize_area (y=12, x=122, rows=6, cols=-2, color=10) at tty-ncurses.c:565 > > #6 0x000056421ef64ec5 in tty_draw_box_shadow (y=11, x=-2, rows=7, cols=124, shadow_color=10) at tty.c:272 > > #7 0x000056421ef27b58 in frame_draw (f=0x56421febb550) at frame.c:80 'cols=-2' looks like a culprit. At a glance https://github.com/MidnightCommander/mc/commit/8b4386df83ab5a525f0568113fe1e53d362f433e does not change the clipping behaviour. But the new calls to draw shadow box were added. In our case new call is: frame.c: if (mc_global.tty.shadows) tty_draw_box_shadow (w->y, w->x, w->lines, w->cols, SHADOW_COLOR); It should call one of tty_colorize_area() below: void tty_draw_box_shadow (int y, int x, int rows, int cols, int shadow_color) { /* draw right shadow */ tty_colorize_area (y + 1, x + cols, rows - 1, 2, shadow_color); /* draw bottom shadow */ tty_colorize_area (y + rows, x + 2, 1, cols, shadow_color); } Looking at the values it's a 'right' case. But 'cols' should be literal '2', not -2. Backtrace probably shows value changed inplace by ncurses-specific tty_clip(). void tty_colorize_area (int y, int x, int rows, int cols, int color) { ... if (!use_colors || !tty_clip (&y, &x, &rows, &cols)) return; ... static gboolean tty_clip (int *y, int *x, int *rows, int *cols) { ... if (*x + *cols > COLS) *cols = COLS - *x; return TRUE; } At a glance the patch itself did not seem to change the clipping logic. But the shadow area can now gnerate boxes of nevative heght: // tty_draw_box_shadow() y=11; x=-2; rows=7; cols=124; // tty_colorize_area (y + 1, x + cols, rows - 1, 2, shadow_color); ('right' case) y = 12; x = 122; rows = 6; cols = 2; // tty_clip() cols = -2; // somehow, perhaps due to: if (*x + *cols > COLS) *cols = COLS - *x; To get negative COLS should be 120. Thus right hand side box clipping is not enough. I think our special trigger here is the huge initial save dialog width of 120 symbols. What locale you are running to get such a box? The simple reproducer seems to be: 1. Build mc with USE=ncurses 2. Shrink the window 3. Attempt to save a file. Would you like to give the patch a try? I'd also be interested in the video of successful safe. Created attachment 685515 [details, diff]
mc-4.8.26-clip-768285.patch
mc-4.8.26-clip-768285.patch should clip consistently
> =================================================================
> Package Settings
> =================================================================
>
> app-misc/mc-4.8.26::gentoo was built with the following:
> USE="edit nls sftp unicode xdg -X -gpm -samba -slang -spell -test" ABI_X86="(64)"
> FEATURES="xattr distlocks binpkg-docompress pid-sandbox userpriv unmerge-logs strict ccache news sandbox cgroup assume-digests userfetch unmerge-orphans qa-unresolved-soname-deps ipc-sandbox downgrade-backup network-sandbox config-protect-if-modified preserve-libs protect-owned usersandbox binpkg-logs binpkg-dostrip unknown-features-warn sfperms fixlafiles multilib-strict merge-sync parallel-fetch ebuild-locks usersync"
>
Now going to test the patch...
Patch works, thank you. The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ea2c3fc6deedb313f1c6aaa49d4e9b87e1b3c805 commit ea2c3fc6deedb313f1c6aaa49d4e9b87e1b3c805 Author: Sergei Trofimovich <slyfox@gentoo.org> AuthorDate: 2021-02-03 08:08:55 +0000 Commit: Sergei Trofimovich <slyfox@gentoo.org> CommitDate: 2021-02-03 08:09:41 +0000 app-misc/mc: fix shadow render on ncurses Reported-by: Thomas Deutschmann Closes: https://bugs.gentoo.org/768285 Package-Manager: Portage-3.0.14, Repoman-3.0.2 Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> app-misc/mc/files/mc-4.8.26-shadow-crash.patch | 39 +++++++++ app-misc/mc/mc-4.8.26-r1.ebuild | 108 +++++++++++++++++++++++++ 2 files changed, 147 insertions(+) |