Skip to content

Segmentation fault in mcedit when going to Options -> Syntax file #4717

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

Open
2 tasks done
zyv opened this issue May 27, 2025 · 6 comments
Open
2 tasks done

Segmentation fault in mcedit when going to Options -> Syntax file #4717

zyv opened this issue May 27, 2025 · 6 comments
Assignees
Labels
area: core Issues not related to a specific subsystem prio: medium Has the potential to affect progress state: in review If not using PRs: associated branch is being reviewed
Milestone

Comments

@zyv
Copy link
Member

zyv commented May 27, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Midnight Commander version and build configuration

~ % ~/src/mc/master/build/install/bin/mc -V  
GNU Midnight Commander 4.8.33-246-gf9ef9069e

Operating system

~ % uname -a
Darwin Mac-1373 24.5.0 Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:29 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T6030 arm64

Is this issue reproducible using the latest version of Midnight Commander?

  • I confirm the issue is still reproducible with the latest version of Midnight Commander

How to reproduce

Start mcedit and go to Options -> Syntax file.

Expected behavior

No segfault.

Actual behavior

(lldb) fr v
(const char *) text = 0x0000000000000000
(const ssize_t) width = -1
(size_t) width1 = 18446744073709551615
(gunichar) uni = 0
(size_t) left = 1
(char *) actual = 0x00000001000d6e40 "\b"

(lldb) bt all
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
  * frame #0: 0x00000001000d6aa0 mc`str_utf8_make_make_term_form(text=0x0000000000000000, width=-1) at strutilutf8.c:457:24
    frame #1: 0x00000001000d5e18 mc`str_utf8_trunc(text=0x0000000000000000, width=-1) at strutilutf8.c:875:16
    frame #2: 0x00000001000cfaa8 mc`str_trunc(text=0x0000000000000000, width=-1) at strutil.c:797:12
    frame #3: 0x00000001000b8764 mc`path_trunc(path=0x0000000000000000, width=-1) at util.c:323:15
    frame #4: 0x0000000100029a30 mc`files_error(ctx=0x00006000015081c0, allow_retry=1, format="Cannot create target file\n%s", file1="/Users/zaytsev/.local/share/mc/syntax/Syntax", file2=0x0000000000000000) at file.c:1126:14
    frame #5: 0x0000000100024f88 mc`file_error(ctx=0x00006000015081c0, allow_retry=1, format="Cannot create target file\n%s", file="/Users/zaytsev/.local/share/mc/syntax/Syntax") at file.c:3734:12
    frame #6: 0x00000001000240e8 mc`copy_file_file(ctx=0x00006000015081c0, src_path="/Users/zaytsev/src/mc/master/build/install/share/mc/syntax/Syntax", dst_path="/Users/zaytsev/.local/share/mc/syntax/Syntax") at file.c:2613:21
    frame #7: 0x000000010000ef64 mc`check_for_default(default_file_vpath=0x0000600002c205e0, file_vpath=0x0000600002c20680) at util.c:68:9
    frame #8: 0x0000000100098cbc mc`edit_load_syntax_file(h=0x0000000112804080) at editcmd.c:1149:9
    frame #9: 0x00000001000a778c mc`edit_dialog_command_execute(h=0x0000000112804080, command=509) at editwidget.c:419:9
    frame #10: 0x00000001000a5b0c mc`edit_dialog_callback(w=0x0000000112804080, sender=0x000060000171c000, msg=MSG_ACTION, parm=509, data=0x0000000000000000) at editwidget.c:776:18
    frame #11: 0x000000010010af34 mc`send_message(w=0x0000000112804080, sender=0x000060000171c000, msg=MSG_ACTION, parm=509, data=0x0000000000000000) at widget-common.h:255:15
    frame #12: 0x000000010010ad0c mc`menubar_execute(menubar=0x000060000171c000) at menu.c:363:9
    frame #13: 0x000000010010a42c mc`menubar_execute_cmd(menubar=0x000060000171c000, command=1) at menu.c:587:13
    frame #14: 0x0000000100109c90 mc`menubar_handle_key(menubar=0x000060000171c000, key=10) at menu.c:614:15
    frame #15: 0x0000000100108f2c mc`menubar_callback(w=0x000060000171c000, sender=0x0000000000000000, msg=MSG_HOTKEY, parm=10, data=0x0000000000000000) at menu.c:679:13
    frame #16: 0x00000001000fdd14 mc`send_message(w=0x000060000171c000, sender=0x0000000000000000, msg=MSG_HOTKEY, parm=10, data=0x0000000000000000) at widget-common.h:255:15
    frame #17: 0x00000001000fd018 mc`group_handle_hotkey(g=0x0000000112804080, key=10) at group.c:552:19
    frame #18: 0x00000001000fc578 mc`group_default_callback(w=0x0000000112804080, sender=0x0000000000000000, msg=MSG_HOTKEY, parm=10, data=0x0000000000000000) at group.c:640:16
    frame #19: 0x00000001000fa7e4 mc`dlg_default_callback(w=0x0000000112804080, sender=0x0000000000000000, msg=MSG_HOTKEY, parm=10, data=0x0000000000000000) at dialog.c:370:16
    frame #20: 0x00000001000a5ccc mc`edit_dialog_callback(w=0x0000000112804080, sender=0x0000000000000000, msg=MSG_HOTKEY, parm=10, data=0x0000000000000000) at editwidget.c:842:16
    frame #21: 0x00000001000fdd14 mc`send_message(w=0x0000000112804080, sender=0x0000000000000000, msg=MSG_HOTKEY, parm=10, data=0x0000000000000000) at widget-common.h:255:15
    frame #22: 0x00000001000fce4c mc`group_handle_key(g=0x0000000112804080, key=10) at group.c:503:15
    frame #23: 0x00000001000fc564 mc`group_default_callback(w=0x0000000112804080, sender=0x0000000000000000, msg=MSG_KEY, parm=10, data=0x0000000000000000) at group.c:637:16
    frame #24: 0x00000001000fb460 mc`dlg_key_event(h=0x0000000112804080, d_key=10) at dialog.c:252:19
    frame #25: 0x00000001000fb124 mc`dlg_process_event(h=0x0000000112804080, key=10, event=0x000000016fdfe720) at dialog.c:539:9
    frame #26: 0x00000001000fb724 mc`frontend_dlg_run(h=0x0000000112804080) at dialog.c:321:9
    frame #27: 0x00000001000fb594 mc`dlg_run(h=0x0000000112804080) at dialog.c:573:5
    frame #28: 0x00000001000a59d0 mc`edit_files(files=0x0000600002c0ff20) at editwidget.c:1272:9
    frame #29: 0x00000001000a5624 mc`edit_file(arg=0x000000016fdfe858) at editwidget.c:1201:10
    frame #30: 0x000000010001ad8c mc`edit_file_at_line(what_vpath=0x0000600002c114e0, internal=1, start_line=0) at cmd.c:650:9
    frame #31: 0x000000010001aea8 mc`do_edit(what_vpath=0x0000600002c114e0) at cmd.c:164:5
    frame #32: 0x000000010001ae60 mc`edit_cmd(panel=0x00000001206055a0) at cmd.c:685:9
    frame #33: 0x0000000100030274 mc`midnight_execute_cmd(sender=0x0000000120605940, command=44) at filemanager.c:1191:9
    frame #34: 0x000000010002fbbc mc`midnight_callback(w=0x0000000121904080, sender=0x0000000120605940, msg=MSG_ACTION, parm=44, data=0x0000000000000000) at filemanager.c:1577:16
    frame #35: 0x00000001000f9488 mc`send_message(w=0x0000000121904080, sender=0x0000000120605940, msg=MSG_ACTION, parm=44, data=0x0000000000000000) at widget-common.h:255:15
    frame #36: 0x00000001000f9198 mc`buttonbar_call(bb=0x0000000120605940, i=3) at buttonbar.c:157:15
    frame #37: 0x00000001000f8c14 mc`buttonbar_callback(w=0x0000000120605940, sender=0x0000000000000000, msg=MSG_HOTKEY, parm=268, data=0x0000000000000000) at buttonbar.c:174:42
    frame #38: 0x00000001000fdd14 mc`send_message(w=0x0000000120605940, sender=0x0000000000000000, msg=MSG_HOTKEY, parm=268, data=0x0000000000000000) at widget-common.h:255:15
    frame #39: 0x00000001000fd0dc mc`group_handle_hotkey(g=0x0000000121904080, key=268) at group.c:566:23
    frame #40: 0x00000001000fc578 mc`group_default_callback(w=0x0000000121904080, sender=0x0000000000000000, msg=MSG_HOTKEY, parm=268, data=0x0000000000000000) at group.c:640:16
    frame #41: 0x00000001000fa7e4 mc`dlg_default_callback(w=0x0000000121904080, sender=0x0000000000000000, msg=MSG_HOTKEY, parm=268, data=0x0000000000000000) at dialog.c:370:16
    frame #42: 0x000000010002fbec mc`midnight_callback(w=0x0000000121904080, sender=0x0000000000000000, msg=MSG_HOTKEY, parm=268, data=0x0000000000000000) at filemanager.c:1584:16
    frame #43: 0x00000001000fdd14 mc`send_message(w=0x0000000121904080, sender=0x0000000000000000, msg=MSG_HOTKEY, parm=268, data=0x0000000000000000) at widget-common.h:255:15
    frame #44: 0x00000001000fce4c mc`group_handle_key(g=0x0000000121904080, key=268) at group.c:503:15
    frame #45: 0x00000001000fc564 mc`group_default_callback(w=0x0000000121904080, sender=0x0000000000000000, msg=MSG_KEY, parm=268, data=0x0000000000000000) at group.c:637:16
    frame #46: 0x00000001000fb460 mc`dlg_key_event(h=0x0000000121904080, d_key=268) at dialog.c:252:19
    frame #47: 0x00000001000fb124 mc`dlg_process_event(h=0x0000000121904080, key=268, event=0x000000016fdfed10) at dialog.c:539:9
    frame #48: 0x00000001000fb724 mc`frontend_dlg_run(h=0x0000000121904080) at dialog.c:321:9
    frame #49: 0x00000001000fb594 mc`dlg_run(h=0x0000000121904080) at dialog.c:573:5
    frame #50: 0x000000010002f4a8 mc`do_nc at filemanager.c:1794:16
    frame #51: 0x0000000100000cf0 mc`main(argc=1, argv=0x000000016fdff500) at main.c:431:21
    frame #52: 0x000000019d142b98 dyld`start + 6076

Additional context

Introduced in 5c2f908 (#4706).

@zyv zyv added prio: medium Has the potential to affect progress needs triage Needs triage by maintainers labels May 27, 2025
@github-actions github-actions bot added this to the Future Releases milestone May 27, 2025
@zyv zyv added area: core Issues not related to a specific subsystem and removed needs triage Needs triage by maintainers labels May 27, 2025
@zyv zyv modified the milestones: Future Releases, 4.8.34 May 27, 2025
aborodin added a commit that referenced this issue May 27, 2025
How to reproduce:
Start mcedit and go to Options -> Syntax file.

Actual behavior:
Segfault.

  * (file_error): pass second file name as an empty string intead of
    NULL to files_error() to avoid NULL dereference in str_utf8_trunc(),
    str_8bit_trunc(), and str_ascii_trunc().

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
@mc-worker mc-worker added area: mcview mcview, the built-in text editor state: in review If not using PRs: associated branch is being reviewed and removed area: mcview mcview, the built-in text editor labels May 27, 2025
Copy link

The changes in the branch associated with this issue are ready for review.

@zyv
Copy link
Member Author

zyv commented May 28, 2025

The segfault has gone, but I've noticed two more issues. What do you think?

Image

@aborodin
Copy link
Member

aborodin commented May 28, 2025 via email

@zyv
Copy link
Member Author

zyv commented May 28, 2025

Fixed in ab0d6f5.

Thank you, the localization is now working correctly! What about directory creation, though?

@aborodin
Copy link
Member

aborodin commented May 28, 2025 via email

@zyv
Copy link
Member Author

zyv commented May 28, 2025

What do you mean?

I mean that when you start mcedit and go to Options -> Syntax File and the syntax directory doesn't exist in your configuration directory — which won't happen unless you manually create it — then it tries to copy the main Syntax file but fails (see the screenshot with the error message). Since mc creates its own configuration directory, I also expect it to create the syntax subdirectory inside when copying the Syntax file to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: core Issues not related to a specific subsystem prio: medium Has the potential to affect progress state: in review If not using PRs: associated branch is being reviewed
Development

When branches are created from issues, their pull requests are automatically linked.

3 participants