]> gitweb.factorcode.org Git - factor.git/commitdiff
threads.test: a test that is mostly able to reproduce #1319
authorBjörn Lindqvist <bjourne@gmail.com>
Wed, 20 May 2015 23:35:43 +0000 (01:35 +0200)
committerDoug Coleman <doug.coleman@gmail.com>
Fri, 22 May 2015 19:22:26 +0000 (12:22 -0700)
basis/threads/threads-tests.factor

index e5812c3fc19bc69f3cb7bb8e195b41c048ae3ad7..b7adb8f8514855a64117f51d2c9fd61d9910867b 100644 (file)
@@ -1,8 +1,34 @@
-USING: namespaces io tools.test threads threads.private kernel
+USING: io memory namespaces tools.test threads threads.private kernel
 concurrency.combinators concurrency.promises locals math
 words calendar sequences fry ;
 IN: threads.tests
 
+! Bug #1319
+! The start-context-and-delete primitive calls reset_context which
+! causes reads to uninitialized locations in the data segment if it
+! gc:s
+
+TUPLE: tup1 a ;
+
+! This word attempts to fill the nursery so that there is less than 48
+! bytes of free space in it. The constant used to fill is volatile but
+! should work on 64 bit.
+: fill-nursery ( -- obj )
+    minor-gc 48074 [ tup1 new ] replicate ;
+
+: do-reset-context ( -- val )
+    ! "main running" print flush
+    [ "a" print ] "foo1" spawn drop
+    [ "b" print ] "foo2" spawn drop
+    [ "c" print ] "foo3"
+    [ fill-nursery ] 2dip
+    spawn drop
+    0 seconds sleep ;
+
+{ 48074 } [
+    do-reset-context length
+] unit-test
+
 3 "x" set
 [ 2 "x" set ] "Test" spawn drop
 [ 2 ] [ yield "x" get ] unit-test