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

curses: calling addch() with an 1-length str segfaults with ncurses6 compiled with --enable-ext-colors #72735

Closed
yyt16384 mannequin opened this issue Oct 28, 2016 · 7 comments
Assignees
Labels
3.7 (EOL) end of life extension-modules C modules in the Modules dir type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@yyt16384
Copy link
Mannequin

yyt16384 mannequin commented Oct 28, 2016

BPO 28549
Nosy @Yhg1s, @serhiy-storchaka, @yyt16384
PRs
  • [Do Not Merge] Convert Misc/NEWS so that it is managed by towncrier #552
  • Files
  • curses_setcchar.patch
  • curses_setcchar_2.patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2016-10-30.21:02:55.466>
    created_at = <Date 2016-10-28.17:51:09.852>
    labels = ['extension-modules', '3.7', 'type-crash']
    title = 'curses: calling addch() with an 1-length str segfaults with ncurses6 compiled with --enable-ext-colors'
    updated_at = <Date 2017-03-31.16:36:30.780>
    user = 'https://github.com/yyt16384'

    bugs.python.org fields:

    activity = <Date 2017-03-31.16:36:30.780>
    actor = 'dstufft'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2016-10-30.21:02:55.466>
    closer = 'serhiy.storchaka'
    components = ['Extension Modules']
    creation = <Date 2016-10-28.17:51:09.852>
    creator = 'yyt16384'
    dependencies = []
    files = ['45254', '45260']
    hgrepos = []
    issue_num = 28549
    keywords = ['patch']
    message_count = 7.0
    messages = ['279620', '279627', '279644', '279660', '279678', '279747', '279750']
    nosy_count = 4.0
    nosy_names = ['twouters', 'python-dev', 'serhiy.storchaka', 'yyt16384']
    pr_nums = ['552']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue28549'
    versions = ['Python 3.5', 'Python 3.6', 'Python 3.7']

    @yyt16384
    Copy link
    Mannequin Author

    yyt16384 mannequin commented Oct 28, 2016

    When addch() is called with an 1-length str, it is converted into a cchar_t. Ncurses6 adds a new field ext_color to cchar_t if it is enabled at compile time, and it is not initialized here, which causes various problems like segfaults or wrong display of characters.

    @yyt16384 yyt16384 mannequin added extension-modules C modules in the Modules dir type-crash A hard crash of the interpreter, possibly with a core dump labels Oct 28, 2016
    @serhiy-storchaka
    Copy link
    Member

    The _curses module uses direct access to cchar_t fields. Proposed patch makes it using setcchar. Does it fixes this issue Yutao?

    @serhiy-storchaka serhiy-storchaka added the 3.7 (EOL) end of life label Oct 28, 2016
    @yyt16384
    Copy link
    Mannequin Author

    yyt16384 mannequin commented Oct 29, 2016

    It fails to compile for me. setcchar should take a cchar_t* and a const wchar_t* instead.

    @serhiy-storchaka
    Copy link
    Member

    Ah, sorry. libncursesw5-dev was not installed on my computer.

    Please try updated patch.

    @yyt16384
    Copy link
    Mannequin Author

    yyt16384 mannequin commented Oct 29, 2016

    Yes, it works for me now.

    @serhiy-storchaka serhiy-storchaka self-assigned this Oct 30, 2016
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Oct 30, 2016

    New changeset d06bf822585c by Serhiy Storchaka in branch '3.5':
    Issue bpo-28549: Fixed segfault in curses's addch() with ncurses6.
    https://hg.python.org/cpython/rev/d06bf822585c

    New changeset 382b3d19e9fc by Serhiy Storchaka in branch '3.6':
    Issue bpo-28549: Fixed segfault in curses's addch() with ncurses6.
    https://hg.python.org/cpython/rev/382b3d19e9fc

    New changeset 11cb97de3edd by Serhiy Storchaka in branch 'default':
    Issue bpo-28549: Fixed segfault in curses's addch() with ncurses6.
    https://hg.python.org/cpython/rev/11cb97de3edd

    @serhiy-storchaka
    Copy link
    Member

    Thank you for testing this.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life extension-modules C modules in the Modules dir type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant