kubo39's blog

ただの雑記です。

nimでsegv

2パターンで。

パターン1

コード1:

import sequtils

var x = cast[string](@[1, 2, 3, 4, 5])

出力1:

% $HOME/Nim/bin/nim -version
Nim Compiler Version 0.11.2 (2015-05-20) [Linux: amd64]
Copyright (c) 2006-2015 by Andreas Rumpf

git hash: 45b6082c12dd6fc90a3dd3ca97e1ba157c3d6464
active boot switches: -d:release
%  $HOME/Nim/bin/nim c hoge.nim
.. (省略)
Hint: operation successful (9696 lines compiled; 0.184 sec total; 14.143MB; Debug Build) [SuccessX]
% ./hoge
Traceback (most recent call last)
hoge.nim(3)              hoge
SIGSEGV: Illegal storage access. (Attempt to read from nil?)

パターン2

コード2:

import sequtils

echo cast[string](@[1, 2, 3, 4, 5])
% $HOME/Nim/bin/nim -version
Nim Compiler Version 0.11.2 (2015-05-20) [Linux: amd64]
Copyright (c) 2006-2015 by Andreas Rumpf

git hash: 45b6082c12dd6fc90a3dd3ca97e1ba157c3d6464
active boot switches: -d:release
%  $HOME/Nim/bin/nim c fuga.nim
.. (省略)
Hint: operation successful (9696 lines compiled; 0.184 sec total; 14.143MB; Debug Build) [SuccessX]
% ./fuga
Traceback (most recent call last)
fuga.nim(3)              fuga
SIGSEGV: Illegal storage access. (Attempt to read from nil?)

原因は同じっぽい気はするけれど、それぞれsegvがでた場所が違ったので一応わけてかいた。 もうちょっと調べて詳細を書く予定。(あくまで予定)

[追記]

github.com

これっぽい?

[追記2]

github.com

バグじゃなかったそうです。