Skip to content

curses.napms() aborts with a SystemError #126313

Closed

Description

@devdanzin

Crash report

What happened?

The abort happens on normal and no-gil debug builds, release builds also hit the SystemError.

import curses
curses.napms(37)

Error is:

Fatal Python error: _Py_CheckFunctionResult: a function returned a result with an exception set
Python runtime state: initialized
_curses.error: must call initscr() first

The above exception was the direct cause of the following exception:

SystemError: <built-in function napms> returned a result with an exception set

Current thread 0x00007fe41a8c3740 (most recent call first):
  File "/home/fusil/python-73/curses-fatal/source.py", line 3 in <module>
Aborted

Found using fusil by @vstinner.

CPython versions tested on:

3.13, 3.14, CPython main branch

Operating systems tested on:

Linux

Output from running 'python -VV' on the command line:

Python 3.14.0a1+ experimental free-threading build (heads/main:d467d9246c, Nov 1 2024, 09:05:56) [GCC 11.4.0]

Linked PRs

Activity

  1. added
    type-crashA hard crash of the interpreter, possibly with a core dump
    on Nov 1, 2024
  2. picnixz commented on Nov 2, 2024

    @picnixz
    Member

    Ah I can see what happened. The macro returns 0 so that it can be used as a substitute for NULL in most of the functions it's being used but _curses.napms returns an int. Instead, it should return -1. It's an easy fix (one should simply remove the macro usage for this one and do something like that:

     if (!_PyCursesStatefulCheckFunction(module,
    								     curses_initscr_called,
    									 "initscr")) {
    	return -1;
    }

    I think it should suffice. I won't make a PR on Saturday (UTC+2) but probably on Sunday.

  3. self-assigned this
    on Nov 2, 2024
  4. changed the title [-]`curses.napms(37)` aborts with a `SystemError`[/-] [+]`curses.napms()` aborts with a `SystemError`[/+] on Nov 2, 2024
  5. added
    3.12only security fixes
    3.13only security fixes
    3.14bugs and security fixes
    on Nov 3, 2024
  6. added a commit that references this issue on Nov 3, 2024
  7. vstinner commented on Nov 4, 2024

    @vstinner
    Member

    Fixed by change 19d9358.

  8. serhiy-storchaka commented on Nov 4, 2024

    @serhiy-storchaka
    Member

    The fix was not backported yet.

  9. picnixz commented on Nov 6, 2024

    @picnixz
    Member

    Update: No need for a 3.12 backport because the implementation returns a PyObject * instead of an int. Only a 3.13 backport is needed (which I am taking care of now).

  10. added a commit that references this issue on Nov 6, 2024
  11. added a commit that references this issue on Nov 6, 2024
  12. vstinner commented on Nov 6, 2024

    @vstinner
    Member

    I merged the 3.13 backport.

  13. added a commit that references this issue on Dec 8, 2024
  14. added a commit that references this issue on Jan 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

3.13only security fixes3.14bugs and security fixesextension-modulesC modules in the Modules dirtype-crashA hard crash of the interpreter, possibly with a core dump

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions