Subject: bug#44724: Uninitialised variables in syntax.c cause trouble.

From: Alan Mackenzie <[email-masked]>
Date: Wed, 18 Nov 2020 20:26:10 +0000

Hello, Martin.

On Wed, Nov 18, 2020 at 18:57:37 +0100, martin rudalics wrote:
>  > In src/syntax.c, there are several uninitialised static variables, one of
>  > which is find_start_value.

>  > It is used in function find_defun_start before being initialised.  The
>  > first use is at L.14 of the function, this:

>  >        && pos >= find_start_value

>  > .  This has the effect of causing a certain (forward-comment -1) (which
>  > calls back_comment, which calls find_defun_start) to fail.

>  > In my test setup (I am writing tests for syntax.c), find_start_value's
>  > value at loading time was randomly 1270, which was spuriously inside the
>  > comment I was trying to scan backwards over.  back_comment thus failed to
>  > recognise the comment, and returned failed.

> Just curious: Did current_buffer == find_start_buffer really succeed
> in your scenario?

Yes it did.  All four comparisons in that block of code succeeded,
causing a spurious value to be returned by find_defun_start.

But now I think that that value was a previously valid one which just
hadn't been updated on buffer changes.

I don't think there's any cache invalidation code associated with this
cache, and I think that's why it gave an invalid result.

> martin

-- 
Alan Mackenzie (Nuremberg, Germany).