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

newruntime: error when modifying a sequence #11524

Closed
bpr opened this issue Jun 17, 2019 · 1 comment

Comments

@bpr
Copy link

commented Jun 17, 2019

proc creates a new sequence, modifies the first value, and then prints it. When compiled with newruntime modifying the value crashes it.

Example

proc main() =
  var a = @[1,2,3]
  a[0] = 4
  echo "a: ", a

when isMainModule:
  main()

Current Output when compiled with nim c --newruntime

Traceback (most recent call last)
/Users/bpr/src/nim/nim-examples/nr_bug00.nim(7) nr_bug00
/Users/bpr/src/nim/nim-examples/nr_bug00.nim(3) main
SIGBUS: Illegal storage access. (Attempt to read from nil?)

Expected Output compiled with nim c -d:danger

a: @[4, 2, 3]

Additional Information

$ nim -v
Nim Compiler Version 0.20.99 [MacOSX: amd64]
Compiled at 2019-06-17
Copyright (c) 2006-2019 by Andreas Rumpf

git hash: c8268330be4de61541aa34eb82f7a93dc62e627c
active boot switches: -d:release
@Araq

This comment has been minimized.

Copy link
Member

commented Jun 19, 2019

Reason: We move the const sequence into a which then points to a readonly data section.

@Araq Araq closed this in 79c721d Jun 21, 2019

narimiran added a commit that referenced this issue Jun 27, 2019

[bugfix] fixes #11524
(cherry picked from commit 79c721d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.