NetBSD Problem Report #55482

From www@netbsd.org  Sat Jul 11 17:37:12 2020
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 3937E1A921A
	for <gnats-bugs@gnats.NetBSD.org>; Sat, 11 Jul 2020 17:37:12 +0000 (UTC)
Message-Id: <20200711173711.4F5E71A921E@mollari.NetBSD.org>
Date: Sat, 11 Jul 2020 17:37:11 +0000 (UTC)
From: jnaman806@gmail.com
Reply-To: jnaman806@gmail.com
To: gnats-bugs@NetBSD.org
Subject: [libcurses] slk_restore() does not restore the slk screen 
X-Send-Pr-Version: www-1.0

>Number:         55482
>Category:       lib
>Synopsis:       [libcurses] slk_restore() does not restore the slk screen
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jul 11 17:40:00 +0000 2020
>Closed-Date:    Mon Jun 28 07:27:05 +0000 2021
>Last-Modified:  Mon Jun 28 07:27:05 +0000 2021
>Originator:     Naman Jain
>Release:        NetBSD 9.0
>Organization:
IIT Kanpur
>Environment:
NetBSD localhost 9.0 NetBSD 9.0 (GENERIC) #0: Fri Feb 14 00:06:28 UTC 2020  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64
>Description:
slk_restore() always returns ERR and hence soft label keys are not restored without doing an explicit refresh.
>How-To-Repeat:
#include <curses.h>
#include <assert.h>

int main() {

    slk_init(0);
    initscr();
    slk_set(1, "first", 0); 
    slk_refresh();
    getch();

    slk_clear();
    slk_refresh();
    getch();

    int err = slk_restore();
    assert(err == OK);  // this assertion fails

    getch();
    endwin();
    return 0;
}

>Fix:
This is probably due to the last label. If this loop is run for only 7/8 labels (https://github.com/NetBSD/src/blob/d889a17013661731f516efa8105dce1e145ffcbe/lib/libcurses/slk.c#L829), it executes well and restores successfully. So, the problem is related to the handling of the last character.

>Release-Note:

>Audit-Trail:

State-Changed-From-To: open->closed
State-Changed-By: blymn@NetBSD.org
State-Changed-When: Mon, 28 Jun 2021 07:27:05 +0000
State-Changed-Why:
slk handling has been fixed.  The assertion in the example code no longer
fires.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.