Subject: bug#23271: CC Mode 5.33 (C/l); Cache failure

From: Alan Mackenzie <[email-masked]>
Date: Tue, 26 Apr 2016 20:08:09 +0000

Hello, Michael.

Sorry about the delayed response.

I think I've tracked down what is causing this cache failure, but I'm
not yet totally convinced by my patch for it.

It seems to be an error in adjusting the cache when the buffer gets
narrowed.  In particular, when the new point-min is inside a brace pair
which was previously recorded in the cache.

Give me a little time, and I'll get back to you with a patch.

-- 
Alan Mackenzie (Nuremberg, Germany).

On Mon, Apr 11, 2016 at 05:22:50PM -0400, Michael Welsh Duggan wrote:
> Tricky recipe this time, as it depends on the size of the frame.  (Font
> lock will reach different locations.

> >>>From emacs -Q, type the following into the *scratch* buffer, followed by C-j:

> (modify-frame-parameters (selected-frame) '((height . 56) (tool-bar-lines . 0) (menu-bar-lines . 0) (width . 96)))
> C-j

> Then, load the attached file, BinaryControlFlow.h.  

> C-x f BinaryControlFlow.h RET

> Turn on cache debugging:

> M-x c-toggle-parse-state-debug RET

> Finally, start paging down with C-v.  In my experiments with this frame
> size, it takes 14 times before it triggers.

> Here's the state spew.  FWIW, the cache looks more correct than the
> "from scratch" version.

> c-parse-state inconsistency at 33929: using cache: (33928 33838 (32429 . 33731) 795 365), from scratch: (33928 33838 (32429 . 33731))
> Old state:
> (setq c-state-cache ’((32429 . 33731) 795 365)  c-state-cache-good-pos 33731  c-state-nonlit-pos-cache ’(53334 50334 47334 44334 41334 38334 35334 32334 29099 26099 23099 20099 17099 13993 10731 7641)  c-state-nonlit-pos-cache-limit 53334  c-state-semi-nonlit-pos-cache ’(32334 29099 26099 23099 20099 17099 13993 10731 7641)  c-state-semi-nonlit-pos-cache-limit 32334  c-state-brace-pair-desert nil  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil  c-parse-state-point 33733)
> c-parse-state inconsistency at 33929: using cache: (33928 33838 (32429 . 33731) 795 365), from scratch: (33928 33838 (32429 . 33731))
> Old state:
> (setq c-state-cache ’(33928 33838 (32429 . 33731) 795 365)  c-state-cache-good-pos 33839  c-state-nonlit-pos-cache ’(53334 50334 47334 44334 41334 38334 35334 32334 29099 26099 23099 20099 17099 13993 10731 7641)  c-state-nonlit-pos-cache-limit 53334  c-state-semi-nonlit-pos-cache ’(32334 29099 26099 23099 20099 17099 13993 10731 7641)  c-state-semi-nonlit-pos-cache-limit 32334  c-state-brace-pair-desert nil  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil  c-parse-state-point 33929)
> c-parse-state inconsistency at 33929: using cache: (33928 33838 (32429 . 33731) 795 365), from scratch: (33928 33838 (32429 . 33731))
> Old state:
> (setq c-state-cache ’(33928 33838 (32429 . 33731) 795 365)  c-state-cache-good-pos 33929  c-state-nonlit-pos-cache ’(53334 50334 47334 44334 41334 38334 35334 32334 29099 26099 23099 20099 17099 13993 10731 7641)  c-state-nonlit-pos-cache-limit 53334  c-state-semi-nonlit-pos-cache ’(32334 29099 26099 23099 20099 17099 13993 10731 7641)  c-state-semi-nonlit-pos-cache-limit 32334  c-state-brace-pair-desert nil  c-state-point-min 1  c-state-point-min-lit-type nil  c-state-point-min-lit-start nil  c-state-min-scan-pos 1  c-state-old-cpp-beg nil  c-state-old-cpp-end nil  c-parse-state-point 33929)

[ .... ]

> Emacs  : GNU Emacs 25.0.91.2 (x86_64-pc-linux-gnu, X toolkit)
>  of 2016-02-14
> Package: CC Mode 5.33 (C/l)
> Buffer Style: gnu
> c-emacs-features: (pps-extended-state col-0-paren posix-char-classes gen-string-delim gen-comment-delim syntax-properties 1-bit)

[ .... ]

> #ifndef ROSE_BinaryAnalysis_ControlFlow_H
> #define ROSE_BinaryAnalysis_ControlFlow_H
> 
> #include "Map.h"
> #include "WorkLists.h"
> 
> #include <boost/foreach.hpp>
> #include <boost/graph/adjacency_list.hpp>
> #include <boost/graph/reverse_graph.hpp>
> #include <boost/graph/depth_first_search.hpp>
> #include <Sawyer/GraphBoost.h>
> 
> class SgNode;
> class SgAsmBlock;
> 
> namespace rose {

[ .... ]

> -- 
> Michael Welsh Duggan
> ([email-masked])