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

[ARC] SIGSEGV with tuple assignment caused by cursor inference #15130

Closed
ghost opened this issue Jul 31, 2020 · 1 comment
Closed

[ARC] SIGSEGV with tuple assignment caused by cursor inference #15130

ghost opened this issue Jul 31, 2020 · 1 comment

Comments

@ghost
Copy link

ghost commented Jul 31, 2020

The bug in #15110 was fixed, but turns out there's another ARC bug affecting https://github.com/PMunch/combparser.

Example

type
  Maybe = object
    value: seq[int]

proc p1(): Maybe =
  let lresult = @[123]
  var lvalue: seq[int]
  var lnext: string
  (lvalue, lnext) = (lresult, ";")
  
  result.value = lvalue

proc main = 
  doAssert p1().value == @[123]

main()

Current Output

Traceback (most recent call last)
/home/dian/Stuff/arctest/combparser/src/combparser.nim(23) combparser
/home/dian/Stuff/arctest/combparser/src/combparser.nim(11) main
/home/dian/Things/Nim/lib/system/alloc.nim(972) dealloc
/home/dian/Things/Nim/lib/system/alloc.nim(871) rawDealloc
/home/dian/Things/Nim/lib/system/avltree.nim(74) del
SIGSEGV: Illegal storage access. (Attempt to read from nil?)

Expected Output

No SIGSEGV, assertions passed

$ nim -v
Nim Compiler Version 1.3.5 [Linux: amd64]
Compiled at 2020-07-30
Copyright (c) 2006-2020 by Andreas Rumpf

git hash: f1971243d3e162889b10b46caab8ba6e98afa92d
active boot switches: -d:release -d:danger
@ghost
Copy link
Author

ghost commented Jul 31, 2020

Seems to work when cursor inference is disabled.
expandArc for p1

var
  lresult
  lvalue
`=`(lresult, [123])
var lnext_cursor: string
let __cursor = (lresult, ";")
lvalue = __cursor[0]
lnext_cursor = __cursor[1]
`=sink`(result.value, lvalue)
`=destroy`(lresult)

for ret:

`=sink`(result.value, input[0 .. 1])

@ghost ghost changed the title [ARC] SIGSEGV with tuple assignment (?) [ARC] SIGSEGV with tuple assignment cased by cursor inference Jul 31, 2020
@ghost ghost changed the title [ARC] SIGSEGV with tuple assignment cased by cursor inference [ARC] SIGSEGV with tuple assignment caused by cursor inference Jul 31, 2020
Araq added a commit that referenced this issue Aug 1, 2020
@Araq Araq closed this as completed in 8e3f51f Aug 1, 2020
mildred pushed a commit to mildred/Nim that referenced this issue Jan 11, 2021
* fixes nim-lang#15130

* you really have to copy from cursors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant