Bug 215373 - Unneeded (?) assertion in ttyinq_line_iterate() from sys/kern/tty_inq.c
Summary: Unneeded (?) assertion in ttyinq_line_iterate() from sys/kern/tty_inq.c
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Mark Johnston
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-12-18 10:00 UTC by Jan Kokemüller
Modified: 2022-04-18 16:22 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Kokemüller 2016-12-18 10:00:28 UTC
On CURRENT r309302 with debuggin on I'm getting assertions like here:
https://lists.freebsd.org/pipermail/freebsd-current/2011-May/024573.html

They seem to happen randomly on key presses.

Is the second "MPASS(tib != NULL);" needed? Is it possible that "tib->tib_next" is NULL on the last loop iteration (i.e. offset gets incremented to ti->ti_end)? The first MPASS should be enough.
Comment 1 Mark Johnston freebsd_committer freebsd_triage 2022-04-12 20:59:37 UTC
(In reply to Jan Kokemüller from comment #0)
5.5 years later, this is exactly right.  The assertion is legitimately false if we are at the very end of the buffer.
Comment 2 commit-hook freebsd_committer freebsd_triage 2022-04-12 21:39:01 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=d769609620931a62ebacbd4f1f5fd048c7e3d7c0

commit d769609620931a62ebacbd4f1f5fd048c7e3d7c0
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2022-04-12 21:30:04 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2022-04-12 21:30:04 +0000

    tty: Remove an incorrect assertion from ttyinq_line_iterate()

    We may legitimately have tib == NULL if we're at the very end of the
    queue.

    PR:             215373
    Reported by:    pho
    MFC after:      1 week
    Sponsored by:   The FreeBSD Foundation

 sys/kern/tty_inq.c | 1 -
 1 file changed, 1 deletion(-)
Comment 3 commit-hook freebsd_committer freebsd_triage 2022-04-18 16:21:00 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=60c952d4724974b877b2ec02784e22b74dab8809

commit 60c952d4724974b877b2ec02784e22b74dab8809
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2022-04-12 21:30:04 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2022-04-18 16:19:57 +0000

    tty: Remove an incorrect assertion from ttyinq_line_iterate()

    We may legitimately have tib == NULL if we're at the very end of the
    queue.

    PR:             215373
    Reported by:    pho
    Sponsored by:   The FreeBSD Foundation

    (cherry picked from commit d769609620931a62ebacbd4f1f5fd048c7e3d7c0)

 sys/kern/tty_inq.c | 1 -
 1 file changed, 1 deletion(-)