From owner-freebsd-bugs@FreeBSD.ORG Wed Sep 19 13:20:04 2012 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 196B81065672 for ; Wed, 19 Sep 2012 13:20:04 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id DC7F68FC12 for ; Wed, 19 Sep 2012 13:20:03 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id q8JDK3qP023179 for ; Wed, 19 Sep 2012 13:20:03 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id q8JDK3jY023178; Wed, 19 Sep 2012 13:20:03 GMT (envelope-from gnats) Resent-Date: Wed, 19 Sep 2012 13:20:03 GMT Resent-Message-Id: <201209191320.q8JDK3jY023178@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Erik Cederstrand Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0A37E1065670 for ; Wed, 19 Sep 2012 13:18:38 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id D0E9C8FC15 for ; Wed, 19 Sep 2012 13:18:37 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.5/8.14.5) with ESMTP id q8JDIbiJ025742 for ; Wed, 19 Sep 2012 13:18:37 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.5/8.14.5/Submit) id q8JDIbOp025741; Wed, 19 Sep 2012 13:18:37 GMT (envelope-from nobody) Message-Id: <201209191318.q8JDIbOp025741@red.freebsd.org> Date: Wed, 19 Sep 2012 13:18:37 GMT From: Erik Cederstrand To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: misc/171777: Enable assert()s in ncurses X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Sep 2012 13:20:04 -0000 >Number: 171777 >Category: misc >Synopsis: Enable assert()s in ncurses >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Wed Sep 19 13:20:03 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Erik Cederstrand >Release: HEAD >Organization: >Environment: >Description: 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. >How-To-Repeat: >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: Index: lib/ncurses/ncurses/ncurses_cfg.h =================================================================== --- lib/ncurses/ncurses/ncurses_cfg.h (revision 240638) +++ lib/ncurses/ncurses/ncurses_cfg.h (working copy) @@ -145,7 +145,6 @@ #define NCURSES_NO_PADDING 1 #define NCURSES_PATHSEP ':' #define NCURSES_VERSION_STRING "5.7.20081102" -#define NDEBUG 1 #define RETSIGTYPE void #define SIG_ATOMIC_T volatile sig_atomic_t #define SIZEOF_SIGNED_CHAR 1 Index: lib/ncurses/config.mk =================================================================== --- lib/ncurses/config.mk (revision 240638) +++ lib/ncurses/config.mk (working copy) @@ -27,8 +27,6 @@ CFLAGS+= -Wall -CFLAGS+= -DNDEBUG - CFLAGS+= -DHAVE_CONFIG_H # everyone needs this Index: contrib/ncurses/include/ncurses_defs =================================================================== --- contrib/ncurses/include/ncurses_defs (revision 240638) +++ contrib/ncurses/include/ncurses_defs (working copy) @@ -171,7 +171,6 @@ NCURSES_EXT_FUNCS NCURSES_NO_PADDING NCURSES_PATHSEP ':' -NDEBUG NEED_PTEM_H NO_LEAKS PURE_TERMINFO >Release-Note: >Audit-Trail: >Unformatted: