Skip to content

Invalid ORC codegen #24960

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

Open
AinTEAsports opened this issue May 19, 2025 · 1 comment
Open

Invalid ORC codegen #24960

AinTEAsports opened this issue May 19, 2025 · 1 comment

Comments

@AinTEAsports
Copy link

Nim Version

2.2.0

Description

When cloning nclap, going to branch unnamed_arguments, commit 2d94607a3366656dfe1a64461dc4e1926b1b6587 and running nimble test, I get a Illegal storage access on an object variant because of a field that is not present in this variant

Current Output

Traceback (most recent call last)
nclap/tests/test1.nim(363) test1
nclap/src/nclap/parser.nim(606) parse
nclap/src/nclap/parser.nim(441) parseArgs
/home/user/.choosenim/toolchains/nim-2.2.0/lib/system.nim(1678) getFirstUnregisteredUnnamedArgument
/home/user/.choosenim/toolchains/nim-2.2.0/lib/system/alloc.nim(1147) alloc
/home/user/.choosenim/toolchains/nim-2.2.0/lib/system/alloc.nim(931) rawAlloc
SIGSEGV: Illegal storage access. (Attempt to read from nil?)
Error: execution of an external program failed: 'nclap/tests/test1'
       Tip: 2 messages have been suppressed, use --verbose to show them.
tools.nim(36)            doCmd

    Error:  Execution failed with exit code 1
        ... Command: /home/user/.nimble/bin/nim c --noNimblePath -d:NimblePkgVersion=0.1.39 --hints:off -r --path:. nclap/tests/test1

Expected Output

Unhandled exception: field 'ua_name' is not accessible for type 'Argument' using 'kind = Flag' [FieldDefect]

Known Workarounds

Compiling with --mm:refc

Additional Information

No response

@AinTEAsports
Copy link
Author

After thorough testing it seems the code isn't the problem or at least not the only problem, the segfaults comes from the standard library module std/unittest, from this test:

test "test":
  let default_target = "127.0.0.1"
  var p = newParser("simple port scanner", DEFAULT_SHOWHELP_SETTINGS, DEFAULT_ENFORCE_SHORT, false, true)

  p
    .addUnnamedArgument("target", default=some(default_target))
    .addFlag("-p", "--ports", "ports to scan", true, true, default=some("1-65535"))
    .addFlag("-n", "--no-log", "does not log anything", false, false)
    .addFlag("-o", "--output", "outputs the content to a file", true)
    .addFlag("-T", "--aggressivity", "outputs the content to a file", true, true)

  let args = p.parse(@["-n", "-T=5"])

  check not ?args.target
  check !args.target == default_target

  check ?args.no_log
  check ?args.aggressivity

When the addUnnamedArgument call (line 6) is removed, the bug doesn't exist anymore

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

2 participants