From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Subject: bug#27476: libguile/memoize.c is not thread safe, so syntax parameter expansion is not thread-safe Date: Mon, 30 Apr 2018 23:39:05 +0200 Message-ID: <874ljstlvq.fsf_-_@gnu.org> References: <87h8vvp1q7.fsf@elephly.net> <87377esu1a.fsf@gnu.org> <87k20nz18u.fsf@igalia.com> <87a81jj5gg.fsf@gnu.org> <87bmlyzxj7.fsf@elephly.net> <87shf44ny0.fsf@elephly.net> <878tfi9x15.fsf@gnu.org> <87h8nstms1.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43171) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fDGWk-0005RY-I0 for bug-guix@gnu.org; Mon, 30 Apr 2018 17:40:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fDGWg-0006Uc-GF for bug-guix@gnu.org; Mon, 30 Apr 2018 17:40:06 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:36504) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fDGWg-0006UL-BO for bug-guix@gnu.org; Mon, 30 Apr 2018 17:40:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fDGWf-0001Rd-Ua for bug-guix@gnu.org; Mon, 30 Apr 2018 17:40:01 -0400 Sender: "Debbugs-submit" Resent-Message-ID: In-Reply-To: <87h8nstms1.fsf@gnu.org> ("Ludovic \=\?utf-8\?Q\?Court\=C3\=A8s\=22'\?\= \=\?utf-8\?Q\?s\?\= message of "Mon, 30 Apr 2018 23:19:42 +0200") List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: Ricardo Wurmus Cc: Andy Wingo , 27476@debbugs.gnu.org ludo@gnu.org (Ludovic Court=C3=A8s) skribis: > With Guile 2.2.3 a similar program triggers a crash very quickly: Even simpler: --8<---------------cut here---------------start------------->8--- $ guile ../guile-debugging/syntax-parms.scm=20 ;;; note: source file /home/ludo/src/guix/../guile-debugging/syntax-parms.s= cm ;;; newer than compiled /home/ludo/.cache/guile/ccache/2.2-LE-8-3.A/h= ome/ludo/src/guile-debugging/syntax-parms.scm.go ;;; note: auto-compilation is enabled, set GUILE_AUTO_COMPILE=3D0 ;;; or pass the --no-auto-compile argument to disable. ;;; compiling /home/ludo/src/guix/../guile-debugging/syntax-parms.scm ;;; compiled /home/ludo/.cache/guile/ccache/2.2-LE-8-3.A/home/ludo/src/guil= e-debugging/syntax-parms.scm.go In /home/ludo/src/guix/../guile-debugging/syntax-parms.scm: 37:17 13 (_) In system/base/compile.scm: 255:6 12 (compile _ #:from _ #:to _ #:env _ #:opts _) 183:32 11 (compile-fold (#f syntax-violation (# # #)) # =E2=80=A6) In ice-9/boot-9.scm: 2312:4 10 (save-module-excursion #) In language/scheme/compile-tree-il.scm: 31:15 9 (_) In ice-9/psyntax.scm: 1234:22 8 (expand-top-sequence (#) =E2=80=A6) In ice-9/boot-9.scm: 222:29 7 (map1 ((10 (3 #((0 . 0)) 2 (1 (11 0 . 0) (7 (3 #() 2 (10 (13 1= 5 5 (guile) list . #f) (5 . #) (11 0 . 0) (11 0 . 1)) () 2) (11 0= . 0)) 10 (. #) =E2=80=A6) =E2=80=A6) #) =E2=80=A6)) 222:17 6 (map1 (10 (3 #((0 . 0)) 2 (1 (11 0 . 0) (7 (3 #() 2 (10 (13 15= 5 (guile) list . #f) (5 . #) (11 0 . 0) (11 0 . 1)) () 2) (11 0 = . 0)) 10 (13 # . #) =E2=80=A6) =E2=80=A6) =E2=80=A6)) In ice-9/psyntax.scm: 2054:19 5 (_ _ (#) (param 1 2) ()) In ice-9/boot-9.scm: 222:17 4 (map1 (#)) In ice-9/psyntax.scm: 2057:27 3 (_ _) 289:10 2 (eval-local-transformer _ _) In ice-9/eval.scm: 718:15 1 (primitive-eval _) In unknown file: 0 (memoize-expression #) ERROR: In procedure memoize-expression: In procedure vector: Wrong type argument in position 1: #(#) C-c C-c $ cat ../guile-debugging/syntax-parms.scm=20 (use-modules (ice-9 threads) (srfi srfi-1) (system base compile)) (compile #f) ;load modules (define-syntax-parameter param (lambda (s) (syntax-case s () ((_ a b) #'(+ a b))))) (define threads (unfold (lambda (x) (> x 100)) (lambda (x) (call-with-new-thread (lambda () (while #t (compile '(begin (param 1 2) (syntax-parameterize ((param (lambda (s) (syntax-case s = () ((_ a b) #'(- a b))))= )) (param 1 2))) #:env (current-module) #:from 'scheme #:to 'tree-il))))) 1+ 0)) (for-each join-thread threads) --8<---------------cut here---------------end--------------->8--- So the problem, AIUI, is that psyntax evaluates syntax parameters using =E2=80=98primitive-eval=E2=80=99 (via =E2=80=98eval-local-transformer=E2=80= =99), but memoization in (ice-9 eval) is not thread-safe, hence the random crashes. Not sure what can be done. Thoughts? Ludo=E2=80=99.