On Tue, Oct 20, 2026 at 12:47:01PM +0200, Patrice Dumas wrote:
> On Tue, Oct 20, 2026 at 05:44:09PM +0800, Aidan Zhai wrote:
> > Bisected to 4167460:
> > 
> > 4167460 2026-10-16 00:30 +0200 Patrice Dumas        o [HEAD]
> > [refs/bisect/bad] read index tag in Info reader and handle tag not
> > being a node name
> > 
> > Steps to reproduce
> > 
> > 1. INFOPATH= info -v infopath-no-defaults=On --init-file /dev/null
> > /usr/local/share/info/texinfo.info
> > 2. M-x last-node
> > 3. nothing happens
> > 
> > Note that you need to open the newly generated `texinfo.info`.
> 
> Indeed, I used the installed texinfo manual to test before.  So it is
> trigered by both the new code that handle the Index tag and having an
> Index tag at the end of the Info file.
> 
> Reading the code (session-cmd.c info_last_node), I do not understand why
>   i = last_node_tag_idx + 1;
> is not done also if count < 0, as afterwards 'i - 1' is used in any
> case.

It's not an off-by-one error.

The for loop looks like:

for (i = 0; count && fb->tags[i]; i++)

The incrementation i++ is done one more time before the loop finishes,
so (i - 1) will be the index of the final tag table entry.

The problem is that the following line is hardly ever executed:

    i = last_node_tag_idx + 1;

It works correctly with a numeric argument that is larger than the
number of nodes: "C-u 999 >" goes to the "General Index" node, while
simply ">" does not.  (">" is bound to the last-node command.)

I've attempted a fix in commit 3ce75c6058c (today's date).

> Also now I get a segfault when I use last-node on the installed
> texinfo manual from 7.3.

This may have been for an unrelated reason, which I have fixed (commit
03a283932, today).

> With the standalone Info reader from 7.3, for the installed Texinfo
> manual without index tags, last-node goes to the last node.  For
> the new texinfo.info manual with the index tag using Ref, the reader
> goes to the index beginning, which would mean that it follows the Ref.
> It is much better than the development version, but I would have
> expected last-node to go to the last node and not to the last anchor,
> given that (! T_IsAnchor) is checked in the 7.3 info reader code.

I expect this is an old bug, hardly ever seen because it is rare to
have an anchor in the last node, which is often an index node, and the
"last-node" command itself may not be used that often.  Also, loading an
anchor (not an index marker) in the last node may have worked, so did not
appear wrong to anybody.  I looked at the source code of Texinfo 4.13
and the source code was very similar.

Reply via email to