slim
slim copied to clipboard
同名のハイパーリンクが、左辺に複数あるときのバグ
以下のコードをコンパイル・実行すると、slimが落ちる。
a($x, $y), b($x) :- hlink($x), hlink($y) | a($x, $y), b($y).
init.
init :- new($x), new($y) | a($x, $y), b($x).
以下のように書き換えれば動く。
a($x, $y), b($z) :- hlink($x), hlink($y), hlink($z), $x == $z | a($x, $y), b($y).
init.
init :- new($x), new($y) | a($x, $y), b($x).
自分の手元の環境(ubuntu)において、developブランチ(最新版)のslimを使用した時、以上の2つのプログラムは正常に動作しました。
・トレース結果 0: init. @5. ---->_init 1: b(!H4). a(!H4,!H6). @5. ---->_axyb 2: b(!H6). a(!H4,!H6). @5. b(!H6). a(!H4,!H6). @5.
多分オプション(--hl)の付け忘れかと思われますが... ちなみに、下の例ではハイパーリンクのオプション無しで動作しました。
私の環境では、最新版のslimで--hlオプションを付けてもSegmentation Faultします。 参考までに、Segmentation Faultする方の中間コードを示します。
Compiled Ruleset @602
Compiled Rule
--atommatch:
spec [2, 2]
--memmatch:
spec [1, 1]
jump [L168, [0], [], []]
--guard:L168:
spec [1, 1]
jump [L161, [0], [], []]
--body:L161:
spec [1, 2]
commit ["_init", 0]
loadruleset [0, @601]
newatom [1, 0, 'init'_0]
enqueueatom [1]
proceed []
Compiled Ruleset @601
Compiled Rule
--atommatch:
spec [2, 6]
--memmatch:
spec [1, 11]
findproccxt [1, 2, 0, 2, 1, 0]
findatom [1, 0, 'a'_2]
findatom [2, 0, 'b'_1]
derefatom [5, 2, 0]
isunary [5]
derefatom [4, 1, 1]
ishlink [4]
derefatom [3, 1, 0]
ishlink [3]
isunary [3]
samefunc [3, 5]
commit ["_axyb", 0]
dequeueatom [1]
dequeueatom [2]
removeatom [1, 0, 'a'_2]
removeatom [2, 0, 'b'_1]
dequeueatom [3]
removeatom [3, 0]
dequeueatom [4]
removeatom [4, 0]
dequeueatom [5]
removeatom [5, 0]
copyatom [6, 0, 3]
copyatom [7, 0, 4]
copyatom [8, 0, 4]
newatom [9, 0, 'a'_2]
newatom [10, 0, 'b'_1]
newlink [9, 0, 6, 0, 0]
newlink [9, 1, 7, 0, 0]
newlink [10, 0, 8, 0, 0]
enqueueatom [10]
enqueueatom [9]
freeatom [1]
freeatom [2]
freeatom [3]
freeatom [4]
freeatom [5]
proceed []
Compiled Rule
--atommatch:
spec [2, 2]
--memmatch:
spec [1, 13]
findatom [1, 0, 'init'_0]
newhlink [2]
getfunc [3, 2]
allocatomindirect[4, 3]
newhlink [5]
getfunc [6, 5]
allocatomindirect[7, 6]
commit ["_init", 0]
dequeueatom [1]
removeatom [1, 0, 'init'_0]
copyatom [8, 0, 4]
copyatom [9, 0, 4]
copyatom [10, 0, 7]
newatom [11, 0, 'a'_2]
newatom [12, 0, 'b'_1]
newlink [11, 0, 8, 0, 0]
newlink [11, 1, 10, 0, 0]
newlink [12, 0, 9, 0, 0]
enqueueatom [12]
enqueueatom [11]
freeatom [1]
freeatom [4]
freeatom [7]
proceed []
Inline
上の中間命令列も手元の環境と研究室のマシンでは正常に動作しました。
多分Mac特有の問題だと考えられます。
@yoshrc セグフォおきますね。
./slim --hl test.il
[1] 34450 segmentation fault ./slim test.il
上記のilで、findproccxt命令を2つ下に移動したら動きました。