GNU bug report logs - #51264
Calling ‘texi-fragment->stexi’ in parallel leads to crashes

Previous Next

Package: guile;

Reported by: Ludovic Courtès <ludo <at> gnu.org>

Date: Mon, 18 Oct 2021 12:55:01 UTC

Severity: important

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 51264 in the body.
You can then email your comments to 51264 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#51264; Package guile. (Mon, 18 Oct 2021 12:55:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ludovic Courtès <ludo <at> gnu.org>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Mon, 18 Oct 2021 12:55:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: bug-guile <at> gnu.org
Subject: Calling ‘texi-fragment->stexi’ in
 parallel leads to crashes
Date: Mon, 18 Oct 2021 14:54:18 +0200
[Message part 1 (text/plain, inline)]
Hello!

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.)

Test case:

[bug-texi-parser-parallel.scm (text/plain, inline)]
(use-modules (guix) (gnu) (texinfo)
             (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 10 proc lst)))

(for-each/maybe-parallel
 (lambda (package)
   (and=> (package-description package)
          (lambda (str)
            (catch 'parser-error
              (lambda ()
                (texi-fragment->stexi str))
              (lambda args
                (pk 'bah! args)
                (error "failed"))))))
 (fold-packages cons '()))
[Message part 3 (text/plain, inline)]
This code crashes when using ‘n-par-for-each’ but passes when run
sequentially:

--8<---------------cut here---------------start------------->8---
$ guix time-machine --commit=9cda21cf20a5c9bdf97e3a6d6c8f901fc3e4307d -- repl -- bug-texi-parser-parallel.scm

;;; (sequential? #f)

;;; (bah! (parser-error #f "Unknown command" codeand))
In thread:
failed

;;; (bah! (parser-error #f "Unknown command" endm))
In thread:
failed

;;; (bah! (parser-error #f "Unknown command" cod))
In thread:
failed

;;; (bah! (parser-error #f "Unknown command" comm))
In thread:
failed

;;; (bah! (parser-error #f "Unknown command" enum))
In thread:
failed

;;; (bah! (parser-error #f "Unknown command" cod))
In thread:
failed

;;; (bah! (parser-error #f "Unknown command" enem))
In thread:
failed


;;; (bah! (parser-error #f "Unknown command" endmand))
In thread:
failed
;;;;; (bah! (parser-error #f "Unknown command" eomm))
In thread:
failed
$ SEQUENTIAL=y guix time-machine --commit=9cda21cf20a5c9bdf97e3a6d6c8f901fc3e4307d -- repl -- bug-texi-parser-parallel.scm

;;; (sequential? "y")
$ guix repl -- <(echo '(pk (version))')

;;; ("3.0.7")
--8<---------------cut here---------------end--------------->8---

The bits shown in the ‘parser-error’ arguments suggests memory
corruption.

Ludo’.

Severity set to 'important' from 'normal' Request was from Ludovic Courtès <ludo <at> gnu.org> to control <at> debbugs.gnu.org. (Mon, 18 Oct 2021 15:52:02 GMT) Full text and rfc822 format available.

Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Fri, 22 Oct 2021 11:57:02 GMT) Full text and rfc822 format available.

Notification sent to Ludovic Courtès <ludo <at> gnu.org>:
bug acknowledged by developer. (Fri, 22 Oct 2021 11:57:02 GMT) Full text and rfc822 format available.

Message #12 received at 51264-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: 51264-done <at> debbugs.gnu.org
Subject: Re: bug#51264: Calling ‘texi-fragment->stexi’ in parallel leads to crashes
Date: Fri, 22 Oct 2021 13:56:22 +0200
[Message part 1 (text/plain, inline)]
Ludovic Courtès <ludo <at> gnu.org> 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:

[bug-texi-parser-parallel.raw.scm (text/plain, inline)]
(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}."))
[Message part 3 (text/plain, inline)]
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’.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 19 Nov 2021 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 152 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.