Subject: Re: bug#51264: Calling ‘texi-fragment->stexi’ in parallel leads to crashes

From: Ludovic Courtès <[email-masked]>
Date: Fri, 22 Oct 2021 13:56:22 +0200

Ludovic Courtès <[email-masked]> skribis:

> I just stumbled upon this bug (here I use Guix to feed Texinfo strings
> but I suppose we could reduce the test case to be Guix-less.)

Here’s a standalone reproducer:

(use-modules (texinfo)
             (sxml simple)
             (ice-9 threads))

(define sequential? (getenv "SEQUENTIAL"))

(define (for-each/maybe-parallel proc lst)
  (if (pk 'sequential? sequential?)
      (for-each proc lst)
      (n-par-for-each 6 proc lst)))

(setvbuf (current-output-port) 'none)
(for-each/maybe-parallel
 (lambda (str)
   (catch 'parser-error
     (lambda ()
       (texi-fragment->stexi str))
     (lambda args
       (pk 'bah! args '<<>> str)
       (error "failed"))))
 (make-list 5000 "Hello @code{world}, this is @emph{Texinfo}."))

It turned out that (sxml ssax input-parse) would reuse the same global
buffer for each call to ‘next-token’ and ‘next-token-of’ (the Texinfo
parser uses the latter).

Fixed in 3b42b1eb526a85e4fac772e1837046e56e3b9bdc.

Ludo’.