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

nimsuggest crashes when using --mm:arc/orc and if an object that contains string or seq is constructed #23867

Closed
doongjohn opened this issue Jul 20, 2024 · 2 comments · Fixed by #23879
Assignees

Comments

@doongjohn
Copy link

doongjohn commented Jul 20, 2024

Description

nimsuggest crashes when using --mm:arc/orc and if an object that contains string or seq is constructed.

# config.nims
--mm: orc
type ObjStr = object
  s: string

let ostr = ObjStr() # <-- nimsuggest crashes
type ObjSeq = object
  s: seq[int]

let oseq = ObjSeq() # <-- nimsuggest crashes

This is really bad because many object contains string or seq. For example any function that raises an exception crashes nimsuggest because the Exception contains msg: string

Nim Version

Nim Compiler Version 2.1.9 [Linux: amd64]
Compiled at 2024-07-20
Copyright (c) 2006-2024 by Andreas Rumpf

git hash: 31ee75f
active boot switches: -d:release

Current Output

> chk src/main.nim
chk     skUnknown               Hint    ???     0       -1      ">> (toplevel): import(dirty): /home/..../src/main.nim [Processing]"      0

fatal.nim(53)            sysFatal
Error: unhandled exception: liftdestructors.nim(639, 5) `t.destructor != nil`  [AssertionDefect]

Expected Output

no error

Possible Solution

No response

Additional Information

The crash happens here:

of tySequence:
if useNoGc(c, t):
useSeqOrStrOp(c, t, body, x, y)
elif optSeqDestructors in c.g.config.globalOptions:
# note that tfHasAsgn is propagated so we need the check on
# 'selectedGC' here to determine if we have the new runtime.
discard considerUserDefinedOp(c, t, body, x, y)
elif tfHasAsgn in t.flags:
if c.kind in {attachedAsgn, attachedSink, attachedDeepCopy}:
body.add newSeqCall(c, x, y)
forallElements(c, t, body, x, y)
else:
defaultOp(c, t, body, x, y)
of tyString:
if useNoGc(c, t):
useSeqOrStrOp(c, t, body, x, y)
elif tfHasAsgn in t.flags:
discard considerUserDefinedOp(c, t, body, x, y)
else:
defaultOp(c, t, body, x, y)

In the function useSeqOrStrOp:

of attachedDestructor:
doAssert t.destructor != nil
body.add destructorCall(c, t.destructor, x)

@SirOlaf
Copy link
Contributor

SirOlaf commented Jul 22, 2024

Have you tried with --v3

@doongjohn
Copy link
Author

Have you tried with --v3

--v3 and --v4 does not crash.

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.

3 participants