Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIGSEGV in asgnRefNoCycle with const sequence #9825

Closed
arnetheduck opened this issue Nov 29, 2018 · 3 comments

Comments

Projects
None yet
4 participants
@arnetheduck
Copy link
Contributor

commented Nov 29, 2018

test.nim:

func empty(T: typedesc): T = discard
const emptyChunk = @(empty(array[100, byte]))

var lst: seq[seq[byte]]
lst.add emptyChunk
[arnetheduck@tempus tmp]$ nim c -r test
Hint: used config file '/home/arnetheduck/.choosenim/toolchains/nim-0.19.0/config/nim.cfg' [Conf]
Hint: system [Processing]
Hint: test [Processing]
CC: test
CC: stdlib_system
Hint:  [Link]
Hint: operation successful (12273 lines compiled; 0.326 sec total; 16.293MiB peakmem; Debug Build) [SuccessX]
Hint: /home/arnetheduck/tmp/test  [Exec]
Traceback (most recent call last)
test.nim(5)              test
gc.nim(273)              asgnRefNoCycle
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
[arnetheduck@tempus tmp]$ nim --version
Nim Compiler Version 0.19.0 [Linux: amd64]
Compiled at 2018-09-26
Copyright (c) 2006-2018 by Andreas Rumpf

git hash: f6c5c636bb1a1f4e1301ae0ba5a8afecef439132
active boot switches: -d:release
@deech

This comment has been minimized.

Copy link
Contributor

commented Dec 7, 2018

I just pulled the HEAD of devel and this appears to not be happening anymore.

But one weird thing I noticed was that when I did echo repr(emptyChunk) it prints:

0x564d1d35c020[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

which is the representation of an array[100,byte] instead of a seq[byte]. I even changed const emptyChunk = ... to const emptyChunk : seq[byte] = ... and it printed it the same way.

@Clyybber

This comment has been minimized.

Copy link
Contributor

commented May 9, 2019

@deech That is expected, since @ sets the length of the seq to the length of the array input.
EDIT: Nevermind, I didn't notice the missing @ in repr's output.

@Araq

This comment has been minimized.

Copy link
Member

commented May 10, 2019

@Clyybber repr doesn't emit "@", that's not a bug.

@Araq Araq closed this in 22881a3 May 10, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.