Debian Bug report logs - #1058041
ncurses: breaks `hg histedit` (_curses.error: endwin() returned ERR)

version graph

Package: src:ncurses; Maintainer for src:ncurses is Ncurses Maintainers <[email protected]>;

Affects: mercurial

Reported by: Julien Cristau <[email protected]>

Date: Mon, 11 Dec 2023 15:27:01 UTC

Severity: important

Found in version ncurses/6.4+20231121-1

Reply or subscribe to this bug.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to [email protected], [email protected], Ncurses Maintainers <[email protected]>:
Bug#1058041; Package src:ncurses. (Mon, 11 Dec 2023 15:27:03 GMT) (full text, mbox, link).


Acknowledgement sent to Julien Cristau <[email protected]>:
New Bug report received and forwarded. Copy sent to [email protected], Ncurses Maintainers <[email protected]>. (Mon, 11 Dec 2023 15:27:04 GMT) (full text, mbox, link).


Message #5 received at [email protected] (full text, mbox, reply):

From: Julien Cristau <[email protected]>
To: Debian Bug Tracking System <[email protected]>
Subject: ncurses: breaks `hg histedit` (_curses.error: endwin() returned ERR)
Date: Mon, 11 Dec 2023 16:22:40 +0100
Source: ncurses
Version: 6.4+20231121-1
Severity: important
Control: affects -1 mercurial
X-Debbugs-Cc: [email protected]

Hi,

Since a ncurses upgrade in testing recently `hg histedit` seems to
crash consistently, upon trying to apply the changes:

> Traceback (most recent call last):
>   File "/usr/bin/hg", line 59, in <module>
>     dispatch.run()
>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 142, in run
>     status = dispatch(req)
>              ^^^^^^^^^^^^^
>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 231, in dispatch
>     status = _rundispatch(req)
>              ^^^^^^^^^^^^^^^^^
>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 275, in _rundispatch
>     ret = _runcatch(req) or 0
>           ^^^^^^^^^^^^^^
>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 456, in _runcatch
>     return _callcatch(ui, _runcatchfunc)
>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 466, in _callcatch
>     return scmutil.callcatch(ui, func)
>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
>   File "/usr/lib/python3/dist-packages/mercurial/scmutil.py", line 152, in callcatch
>     return func()
>            ^^^^^^
>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 446, in _runcatchfunc
>     return _dispatch(req)
>            ^^^^^^^^^^^^^^
>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 1271, in _dispatch
>     return runcommand(
>            ^^^^^^^^^^^
>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 904, in runcommand
>     ret = _runcommand(ui, options, cmd, d)
>           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 1283, in _runcommand
>     return cmdfunc()
>            ^^^^^^^^^
>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 1269, in <lambda>
>     d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
>                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>   File "/usr/lib/python3/dist-packages/mercurial/util.py", line 1878, in check
>     return func(*args, **kwargs)
>            ^^^^^^^^^^^^^^^^^^^^^
>   File "/usr/lib/python3/dist-packages/hgext/histedit.py", line 1918, in histedit
>     return _chistedit(ui, repo, freeargs, opts)
>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>   File "/usr/lib/python3/dist-packages/hgext/histedit.py", line 1764, in _chistedit
>     curses.endwin()
> _curses.error: endwin() returned ERR

Downgrading to the bookworm version (6.4-4) fixes it.

Cheers,
Julien



Added indication that 1058041 affects mercurial Request was from Julien Cristau <[email protected]> to [email protected]. (Mon, 11 Dec 2023 15:27:04 GMT) (full text, mbox, link).


Information forwarded to [email protected], Ncurses Maintainers <[email protected]>:
Bug#1058041; Package src:ncurses. (Mon, 11 Dec 2023 16:51:03 GMT) (full text, mbox, link).


Acknowledgement sent to Sven Joachim <[email protected]>:
Extra info received and forwarded to list. Copy sent to Ncurses Maintainers <[email protected]>. (Mon, 11 Dec 2023 16:51:03 GMT) (full text, mbox, link).


Message #12 received at [email protected] (full text, mbox, reply):

From: Sven Joachim <[email protected]>
To: Julien Cristau <[email protected]>
Cc: [email protected]
Subject: Re: Bug#1058041: ncurses: breaks `hg histedit` (_curses.error: endwin() returned ERR)
Date: Mon, 11 Dec 2023 17:47:23 +0100
On 2023-12-11 16:22 +0100, Julien Cristau wrote:

> Source: ncurses
> Version: 6.4+20231121-1
> Severity: important
> Control: affects -1 mercurial
> X-Debbugs-Cc: [email protected]
>
> Hi,
>
> Since a ncurses upgrade in testing recently `hg histedit` seems to
> crash consistently, upon trying to apply the changes:
>
>> Traceback (most recent call last):
>>   File "/usr/bin/hg", line 59, in <module>
>>     dispatch.run()
>>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 142, in run
>>     status = dispatch(req)
>>              ^^^^^^^^^^^^^
>>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 231, in dispatch
>>     status = _rundispatch(req)
>>              ^^^^^^^^^^^^^^^^^
>>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 275, in _rundispatch
>>     ret = _runcatch(req) or 0
>>           ^^^^^^^^^^^^^^
>>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 456, in _runcatch
>>     return _callcatch(ui, _runcatchfunc)
>>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 466, in _callcatch
>>     return scmutil.callcatch(ui, func)
>>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>   File "/usr/lib/python3/dist-packages/mercurial/scmutil.py", line 152, in callcatch
>>     return func()
>>            ^^^^^^
>>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 446, in _runcatchfunc
>>     return _dispatch(req)
>>            ^^^^^^^^^^^^^^
>>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 1271, in _dispatch
>>     return runcommand(
>>            ^^^^^^^^^^^
>>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 904, in runcommand
>>     ret = _runcommand(ui, options, cmd, d)
>>           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 1283, in _runcommand
>>     return cmdfunc()
>>            ^^^^^^^^^
>>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 1269, in <lambda>
>>     d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
>>                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>   File "/usr/lib/python3/dist-packages/mercurial/util.py", line 1878, in check
>>     return func(*args, **kwargs)
>>            ^^^^^^^^^^^^^^^^^^^^^
>>   File "/usr/lib/python3/dist-packages/hgext/histedit.py", line 1918, in histedit
>>     return _chistedit(ui, repo, freeargs, opts)
>>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>   File "/usr/lib/python3/dist-packages/hgext/histedit.py", line 1764, in _chistedit
>>     curses.endwin()
>> _curses.error: endwin() returned ERR

I am not familiar with Mercurial, but most likely this has been
triggered by the following change in the 2023111 patchlevel:

,----
| 20231111
| 	+ modify endwin() to return an error if it is called again without an
| 	  intervening screen update (report by Rajeev Pillai, NetBSD #57592).
`----

NetBSD #57592 is
https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=57592 .

Cheers,
       Sven



Information forwarded to [email protected], Ncurses Maintainers <[email protected]>:
Bug#1058041; Package src:ncurses. (Mon, 11 Dec 2023 20:15:03 GMT) (full text, mbox, link).


Acknowledgement sent to Sven Joachim <[email protected]>:
Extra info received and forwarded to list. Copy sent to Ncurses Maintainers <[email protected]>. (Mon, 11 Dec 2023 20:15:03 GMT) (full text, mbox, link).


Message #17 received at [email protected] (full text, mbox, reply):

From: Sven Joachim <[email protected]>
To: Julien Cristau <[email protected]>
Cc: [email protected]
Subject: Re: Bug#1058041: ncurses: breaks `hg histedit` (_curses.error: endwin() returned ERR)
Date: Mon, 11 Dec 2023 21:12:35 +0100
On 2023-12-11 17:47 +0100, Sven Joachim wrote:

> On 2023-12-11 16:22 +0100, Julien Cristau wrote:
>
>> Source: ncurses
>> Version: 6.4+20231121-1
>> Severity: important
>> Control: affects -1 mercurial
>> X-Debbugs-Cc: [email protected]
>>
>> Hi,
>>
>> Since a ncurses upgrade in testing recently `hg histedit` seems to
>> crash consistently, upon trying to apply the changes:
>>
>>> Traceback (most recent call last):
>>>   File "/usr/bin/hg", line 59, in <module>
>>>     dispatch.run()
>>>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 142, in run
>>>     status = dispatch(req)
>>>              ^^^^^^^^^^^^^
>>>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 231, in dispatch
>>>     status = _rundispatch(req)
>>>              ^^^^^^^^^^^^^^^^^
>>>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 275, in _rundispatch
>>>     ret = _runcatch(req) or 0
>>>           ^^^^^^^^^^^^^^
>>>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 456, in _runcatch
>>>     return _callcatch(ui, _runcatchfunc)
>>>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 466, in _callcatch
>>>     return scmutil.callcatch(ui, func)
>>>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>>   File "/usr/lib/python3/dist-packages/mercurial/scmutil.py", line 152, in callcatch
>>>     return func()
>>>            ^^^^^^
>>>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 446, in _runcatchfunc
>>>     return _dispatch(req)
>>>            ^^^^^^^^^^^^^^
>>>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 1271, in _dispatch
>>>     return runcommand(
>>>            ^^^^^^^^^^^
>>>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 904, in runcommand
>>>     ret = _runcommand(ui, options, cmd, d)
>>>           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 1283, in _runcommand
>>>     return cmdfunc()
>>>            ^^^^^^^^^
>>>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 1269, in <lambda>
>>>     d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
>>>                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>>   File "/usr/lib/python3/dist-packages/mercurial/util.py", line 1878, in check
>>>     return func(*args, **kwargs)
>>>            ^^^^^^^^^^^^^^^^^^^^^
>>>   File "/usr/lib/python3/dist-packages/hgext/histedit.py", line 1918, in histedit
>>>     return _chistedit(ui, repo, freeargs, opts)
>>>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>>>   File "/usr/lib/python3/dist-packages/hgext/histedit.py", line 1764, in _chistedit
>>>     curses.endwin()
>>> _curses.error: endwin() returned ERR
>
> I am not familiar with Mercurial, but most likely this has been
> triggered by the following change in the 2023111 patchlevel:
>
> ,----
> | 20231111
> | 	+ modify endwin() to return an error if it is called again without an
> | 	  intervening screen update (report by Rajeev Pillai, NetBSD #57592).
> `----

I now had a look at the histedit code, and it does this:

,----
|         with util.with_lc_ctype():
|             rc = curses.wrapper(functools.partial(_chisteditmain, repo, rules))
|         curses.echo()
|         curses.endwin()
`----

AFAICS, invoking curses.echo() and curses.endwin() is superfluous
because curses.wrapper already does that for you, and calling
curses.endwin() twice throws an error with the newer ncurses.  Removing
those two lines should fix the problem.

Cheers,
       Sven



Information forwarded to [email protected], Ncurses Maintainers <[email protected]>:
Bug#1058041; Package src:ncurses. (Mon, 11 Dec 2023 20:27:04 GMT) (full text, mbox, link).


Acknowledgement sent to [email protected]:
Extra info received and forwarded to list. Copy sent to Ncurses Maintainers <[email protected]>. (Mon, 11 Dec 2023 20:27:04 GMT) (full text, mbox, link).


Message #22 received at [email protected] (full text, mbox, reply):

From: Thomas Dickey <[email protected]>
To: Sven Joachim <[email protected]>, [email protected]
Cc: Julien Cristau <[email protected]>
Subject: Re: Bug#1058041: ncurses: breaks `hg histedit` (_curses.error: endwin() returned ERR)
Date: Mon, 11 Dec 2023 15:12:25 -0500
[Message part 1 (text/plain, inline)]
On Mon, Dec 11, 2023 at 05:47:23PM +0100, Sven Joachim wrote:
> On 2023-12-11 16:22 +0100, Julien Cristau wrote:
> 
> > Source: ncurses
> > Version: 6.4+20231121-1
> > Severity: important
> > Control: affects -1 mercurial
> > X-Debbugs-Cc: [email protected]
> >
> > Hi,
> >
> > Since a ncurses upgrade in testing recently `hg histedit` seems to
> > crash consistently, upon trying to apply the changes:
> >
> >> Traceback (most recent call last):
> >>   File "/usr/bin/hg", line 59, in <module>
> >>     dispatch.run()
> >>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 142, in run
> >>     status = dispatch(req)
> >>              ^^^^^^^^^^^^^
> >>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 231, in dispatch
> >>     status = _rundispatch(req)
> >>              ^^^^^^^^^^^^^^^^^
> >>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 275, in _rundispatch
> >>     ret = _runcatch(req) or 0
> >>           ^^^^^^^^^^^^^^
> >>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 456, in _runcatch
> >>     return _callcatch(ui, _runcatchfunc)
> >>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> >>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 466, in _callcatch
> >>     return scmutil.callcatch(ui, func)
> >>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
> >>   File "/usr/lib/python3/dist-packages/mercurial/scmutil.py", line 152, in callcatch
> >>     return func()
> >>            ^^^^^^
> >>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 446, in _runcatchfunc
> >>     return _dispatch(req)
> >>            ^^^^^^^^^^^^^^
> >>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 1271, in _dispatch
> >>     return runcommand(
> >>            ^^^^^^^^^^^
> >>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 904, in runcommand
> >>     ret = _runcommand(ui, options, cmd, d)
> >>           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> >>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 1283, in _runcommand
> >>     return cmdfunc()
> >>            ^^^^^^^^^
> >>   File "/usr/lib/python3/dist-packages/mercurial/dispatch.py", line 1269, in <lambda>
> >>     d = lambda: util.checksignature(func)(ui, *args, **strcmdopt)
> >>                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> >>   File "/usr/lib/python3/dist-packages/mercurial/util.py", line 1878, in check
> >>     return func(*args, **kwargs)
> >>            ^^^^^^^^^^^^^^^^^^^^^
> >>   File "/usr/lib/python3/dist-packages/hgext/histedit.py", line 1918, in histedit
> >>     return _chistedit(ui, repo, freeargs, opts)
> >>            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> >>   File "/usr/lib/python3/dist-packages/hgext/histedit.py", line 1764, in _chistedit
> >>     curses.endwin()
> >> _curses.error: endwin() returned ERR
> 
> I am not familiar with Mercurial, but most likely this has been
> triggered by the following change in the 2023111 patchlevel:
> 
> ,----
> | 20231111
> | 	+ modify endwin() to return an error if it is called again without an
> | 	  intervening screen update (report by Rajeev Pillai, NetBSD #57592).
> `----
> 
> NetBSD #57592 is
> https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=57592 .

sounds plausible.  fwiw, handling error returns (other than throwing an
exception) is something that developers should do.

I suspect that making ncurses not return error-codes is a step in the wrong
direction.  The example in the NetBSD bug report was clearly a defect in
the application using ncurses.

In this case, I chose to make it behave like SVr4 curses.  Explaining this
nicely in a portability section of the manpage is still on my to-do list,
but it's clear in the note that I made.  NetBSD curses returns no error,
but it's based on some code to handle SIGTSTP.

-- 
Thomas E. Dickey <[email protected]>
https://invisible-island.net
[signature.asc (application/pgp-signature, inline)]

Information forwarded to [email protected], Ncurses Maintainers <[email protected]>:
Bug#1058041; Package src:ncurses. (Tue, 12 Dec 2023 10:57:07 GMT) (full text, mbox, link).


Acknowledgement sent to Julien Cristau <[email protected]>:
Extra info received and forwarded to list. Copy sent to Ncurses Maintainers <[email protected]>. (Tue, 12 Dec 2023 10:57:07 GMT) (full text, mbox, link).


Message #27 received at [email protected] (full text, mbox, reply):

From: Julien Cristau <[email protected]>
To: Sven Joachim <[email protected]>
Cc: [email protected]
Subject: Re: Bug#1058041: ncurses: breaks `hg histedit` (_curses.error: endwin() returned ERR)
Date: Tue, 12 Dec 2023 11:55:42 +0100
Hi Sven,

On Mon, Dec 11, 2023 at 21:12:35 +0100, Sven Joachim wrote:

> On 2023-12-11 17:47 +0100, Sven Joachim wrote:
> 
> > On 2023-12-11 16:22 +0100, Julien Cristau wrote:
> >>> _curses.error: endwin() returned ERR
> >
> > I am not familiar with Mercurial, but most likely this has been
> > triggered by the following change in the 2023111 patchlevel:
> >
> > ,----
> > | 20231111
> > | 	+ modify endwin() to return an error if it is called again without an
> > | 	  intervening screen update (report by Rajeev Pillai, NetBSD #57592).
> > `----
> 
> I now had a look at the histedit code, and it does this:
> 
> ,----
> |         with util.with_lc_ctype():
> |             rc = curses.wrapper(functools.partial(_chisteditmain, repo, rules))
> |         curses.echo()
> |         curses.endwin()
> `----
> 
> AFAICS, invoking curses.echo() and curses.endwin() is superfluous
> because curses.wrapper already does that for you, and calling
> curses.endwin() twice throws an error with the newer ncurses.  Removing
> those two lines should fix the problem.
> 
Thanks a lot for taking a look, and for the hint!

I can confirm this appears to work; I've reported the issue to mercurial
upstream (https://bz.mercurial-scm.org/show_bug.cgi?id=6859) and opened
a MR
(https://foss.heptapod.net/mercurial/mercurial-devel/-/merge_requests/730).

Cheers,
Julien



Information forwarded to [email protected], Ncurses Maintainers <[email protected]>:
Bug#1058041; Package src:ncurses. (Sat, 16 Dec 2023 09:51:02 GMT) (full text, mbox, link).


Acknowledgement sent to Sven Joachim <[email protected]>:
Extra info received and forwarded to list. Copy sent to Ncurses Maintainers <[email protected]>. (Sat, 16 Dec 2023 09:51:02 GMT) (full text, mbox, link).


Message #32 received at [email protected] (full text, mbox, reply):

From: Sven Joachim <[email protected]>
To: Thomas Dickey <[email protected]>
Cc: [email protected], Julien Cristau <[email protected]>
Subject: Re: Bug#1058041: ncurses: breaks `hg histedit` (_curses.error: endwin() returned ERR)
Date: Sat, 16 Dec 2023 10:48:33 +0100
On 2023-12-11 15:12 -0500, Thomas Dickey wrote:

> On Mon, Dec 11, 2023 at 05:47:23PM +0100, Sven Joachim wrote:
>>
>> I am not familiar with Mercurial, but most likely this has been
>> triggered by the following change in the 2023111 patchlevel:
>>
>> ,----
>> | 20231111
>> | 	+ modify endwin() to return an error if it is called again without an
>> | 	  intervening screen update (report by Rajeev Pillai, NetBSD #57592).
>> `----
>>
>> NetBSD #57592 is
>> https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=57592 .
>
> sounds plausible.  fwiw, handling error returns (other than throwing an
> exception) is something that developers should do.

I may be something that developers should do, but in the case of
endwin() hardly anybody does it.  In C/C++ programs, nobody seems to
check the return value of endwin() in the first place, so this change is
not really going to make a difference.

In Python the situation is different, because a curses.error exception
occurs.  The wrapper does not handle it, FWIW.

> I suspect that making ncurses not return error-codes is a step in the wrong
> direction.  The example in the NetBSD bug report was clearly a defect in
> the application using ncurses.

The question is how many such defects are there, and how do we find
them?  Based on the current report I looked on codesearch.debian.net for
more instances where programs make the same mistake as mercurial (using
both curses.wrapper and calling curses.endwin() explicitly).  I could
not find something as broken as the current case, but there seem to be a
few instances where programs call curses.endwin() in a signal handler,
and that may cause issues like #1058626 in pulsemixer.

> In this case, I chose to make it behave like SVr4 curses.  Explaining this
> nicely in a portability section of the manpage is still on my to-do list,
> but it's clear in the note that I made.  NetBSD curses returns no error,
> but it's based on some code to handle SIGTSTP.

I think it is too late to change behavior in ncurses.  This change is
going to cause problems for end users which outweigh any benefits from
forcing changes in non-conforming applications, IMHO.

Cheers,
       Sven



Information forwarded to [email protected], Ncurses Maintainers <[email protected]>:
Bug#1058041; Package src:ncurses. (Sat, 16 Dec 2023 12:15:02 GMT) (full text, mbox, link).


Acknowledgement sent to [email protected]:
Extra info received and forwarded to list. Copy sent to Ncurses Maintainers <[email protected]>. (Sat, 16 Dec 2023 12:15:02 GMT) (full text, mbox, link).


Message #37 received at [email protected] (full text, mbox, reply):

From: Thomas Dickey <[email protected]>
To: Sven Joachim <[email protected]>
Cc: Thomas Dickey <[email protected]>, [email protected], Julien Cristau <[email protected]>
Subject: Re: Bug#1058041: ncurses: breaks `hg histedit` (_curses.error: endwin() returned ERR)
Date: Sat, 16 Dec 2023 07:10:07 -0500
[Message part 1 (text/plain, inline)]
On Sat, Dec 16, 2023 at 10:48:33AM +0100, Sven Joachim wrote:
> On 2023-12-11 15:12 -0500, Thomas Dickey wrote:
> 
> > On Mon, Dec 11, 2023 at 05:47:23PM +0100, Sven Joachim wrote:
> >>
> >> I am not familiar with Mercurial, but most likely this has been
> >> triggered by the following change in the 2023111 patchlevel:
> >>
> >> ,----
> >> | 20231111
> >> | 	+ modify endwin() to return an error if it is called again without an
> >> | 	  intervening screen update (report by Rajeev Pillai, NetBSD #57592).
> >> `----
> >>
> >> NetBSD #57592 is
> >> https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=57592 .
> >
> > sounds plausible.  fwiw, handling error returns (other than throwing an
> > exception) is something that developers should do.
> 
> I may be something that developers should do, but in the case of
> endwin() hardly anybody does it.  In C/C++ programs, nobody seems to
> check the return value of endwin() in the first place, so this change is
> not really going to make a difference.
> 
> In Python the situation is different, because a curses.error exception
> occurs.  The wrapper does not handle it, FWIW.
> 
> > I suspect that making ncurses not return error-codes is a step in the wrong
> > direction.  The example in the NetBSD bug report was clearly a defect in
> > the application using ncurses.
> 
> The question is how many such defects are there, and how do we find
> them?  Based on the current report I looked on codesearch.debian.net for
> more instances where programs make the same mistake as mercurial (using
> both curses.wrapper and calling curses.endwin() explicitly).  I could

which does this:

    finally:
        # Set everything back to normal
        if 'stdscr' in locals():
            stdscr.keypad(0)
            curses.echo()
            curses.nocbreak()
            curses.endwin()

(and appears to have its own problems with copy/paste: the settings changes
are redundant).

> not find something as broken as the current case, but there seem to be a
> few instances where programs call curses.endwin() in a signal handler,
> and that may cause issues like #1058626 in pulsemixer.
> 
> > In this case, I chose to make it behave like SVr4 curses.  Explaining this
> > nicely in a portability section of the manpage is still on my to-do list,
> > but it's clear in the note that I made.  NetBSD curses returns no error,
> > but it's based on some code to handle SIGTSTP.
> 
> I think it is too late to change behavior in ncurses.  This change is
> going to cause problems for end users which outweigh any benefits from
> forcing changes in non-conforming applications, IMHO.

If I weren't spending about a quarter of my time repairing configure scripts
broken by "improvements" to compiler warnings, I'd be more agreeable.

-- 
Thomas E. Dickey <[email protected]>
https://invisible-island.net
[signature.asc (application/pgp-signature, inline)]

Send a report that this bug log contains spam.


Debian bug tracking system administrator <[email protected]>. Last modified: Fri May 16 05:43:03 2025; Machine Name: buxtehude

Debian Bug tracking system

Debbugs is free software and licensed under the terms of the GNU General Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.