Bug 171777 - [ncurses] [patch] Enable assert()s in ncurses
Summary: [ncurses] [patch] Enable assert()s in ncurses
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs mailing list
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2012-09-19 14:20 UTC by Erik Cederstrand
Modified: 2018-05-20 23:50 UTC (History)
0 users

See Also:


Attachments
file.diff (1.06 KB, patch)
2012-09-19 14:20 UTC, Erik Cederstrand
no flags Details | Diff
Remove unconditional NDEBUG (285 bytes, patch)
2016-09-19 11:41 UTC, Erik Cederstrand
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Erik Cederstrand 2012-09-19 14:20:03 UTC
ncurses unconditionally sets NDEBUG to either 0 or 1 in code. include/assert.h disables assert()'s if NDEBUG is set, so assert()'s are never enabled in ncurses. This leads to this report http://scan.freebsd.your.org/freebsd-head/lib.ncurses.menu/2012-09-16-amd64/report-3vc5Zu.html#Path5 and ca. 25 others in ncurses.

Fix: Fix this by removing NDEBUG from contrib/ncurses/include/ncurses_defs. The comment at the top of that file even says not to define NDEBUG there, and it's been fixed in ncurses 5.9 which is in the vendor area in SVN.

Also remove two instances in lib/ncurses where NDEBUG is set unconditionally.

The attached patch allows Clang Analyzer to reason correctly about the code. It's still possible to build ncurses without assert()s by adding -DNDEBUG to CFLAGS when building.

I'm assuming that ncurses is not performance-critical in the default use and that enabling assert()s is OK. From a user perspective, it's better to get an assertion error with the real problem than a null pointer dereference error or garbage data.

Patch attached with submission follows:
Comment 1 Erik Cederstrand 2016-09-19 11:41:53 UTC
Created attachment 174958 [details]
Remove unconditional NDEBUG
Comment 2 Eitan Adler freebsd_committer freebsd_triage 2018-05-20 23:50:47 UTC
For bugs matching the following conditions:
- Status == In Progress
- Assignee == "bugs@FreeBSD.org"
- Last Modified Year <= 2017

Do
- Set Status to "Open"