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

simple 'var openarray[char]' assignment crash when the openarray source is a local string and using gc:arc #14003

Closed
jangko opened this issue Apr 17, 2020 · 1 comment · Fixed by #14006

Comments

@jangko
Copy link
Contributor

jangko commented Apr 17, 2020

This simple nonce[1] = char(65) crash. it works with default gc but not with gc:arc

Example

proc cryptCTR*(nonce: var openArray[char]) =
  nonce[1] = char(65)

proc main() =
  var nonce = "0123456701234567"
  cryptCTR(nonce.toOpenArray(0, nonce.len-1))
  debugEcho nonce
  
main()

Current Output

SIGSEGV: Illegal storage access. (Attempt to read from nil?)

Expected Output

0A23456701234567
$ nim -v
Nim Compiler Version 1.3.1 [Windows: amd64]
Compiled at 2020-04-09
Copyright (c) 2006-2020 by Andreas Rumpf

git hash: b4e9f8e814373fc38741736197d88475663ce758
active boot switches: -d:release
@cooldome
Copy link
Member

cooldome commented Apr 17, 2020

Needs PrepareForMutation before calling a function cryptCTR. I guess codegen can do it.

cooldome pushed a commit that referenced this issue Apr 17, 2020
Araq pushed a commit that referenced this issue Apr 17, 2020
narimiran pushed a commit that referenced this issue Apr 23, 2020
Co-authored-by: cooldome <[email protected]>
(cherry picked from commit f10689d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants