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

Objects can protect illegal recursion but tuples cant #23885

Open
Graveflo opened this issue Jul 23, 2024 · 4 comments
Open

Objects can protect illegal recursion but tuples cant #23885

Graveflo opened this issue Jul 23, 2024 · 4 comments

Comments

@Graveflo
Copy link
Contributor

Graveflo commented Jul 23, 2024

Description

Posting this so I don't forget, it might have been documented already. This appears to sigsev the compiler on a version before #23869 and now infinitely recurses. I guess that means it may be solvable from the same place IE liftParamType

type
  EventHandler = proc(target: BB)
  BB = (EventHandler,)

but this is fine:

type
  EventHandler = proc(target: House)
  BB = (EventHandler,)
  House = object
    a: BB

Nim Version

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

git hash: 8d7f932

Current Output

infinite recursion

Expected Output

not sure really

Possible Solution

No response

Additional Information

No response

@Graveflo
Copy link
Contributor Author

This example comes from a CI failure in an unrelated PR that is crashing code very similar in karax:

https://github.com/karaxnim/karax/blob/f4014d134ff48e118eb4810e9ebceb2920f1af1b/karax/vdom.nim#L152

@Graveflo Graveflo changed the title I think I introduced a regression Objects can protect illegal recursion but tuples cant Jul 23, 2024
@juancarlospaco
Copy link
Collaborator

!nim c

type
  EventHandler = proc(target: BB)
  BB = (EventHandler,)

Copy link
Contributor

🐧 Linux bisect by @juancarlospaco (collaborator)
devel 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

IR

Compiled filesize 0 (0 bytes)

Stats

  • Started 2024-07-23T23:32:44
  • Finished 2024-07-23T23:32:45
  • Duration

AST

nnkStmtList.newTree(
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("EventHandler"),
      newEmptyNode(),
      nnkProcTy.newTree(
        nnkFormalParams.newTree(
          newEmptyNode(),
          nnkIdentDefs.newTree(
            newIdentNode("target"),
            newIdentNode("BB"),
            newEmptyNode()
          )
        ),
        newEmptyNode()
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("BB"),
      newEmptyNode(),
      nnkTupleConstr.newTree(
        newIdentNode("EventHandler")
      )
    )
  )
)
stable 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

IR

Compiled filesize 0 (0 bytes)

Stats

  • Started 2024-07-23T23:32:55
  • Finished 2024-07-23T23:32:56
  • Duration

AST

nnkStmtList.newTree(
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("EventHandler"),
      newEmptyNode(),
      nnkProcTy.newTree(
        nnkFormalParams.newTree(
          newEmptyNode(),
          nnkIdentDefs.newTree(
            newIdentNode("target"),
            newIdentNode("BB"),
            newEmptyNode()
          )
        ),
        newEmptyNode()
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("BB"),
      newEmptyNode(),
      nnkTupleConstr.newTree(
        newIdentNode("EventHandler")
      )
    )
  )
)
2.0.4 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

IR

Compiled filesize 0 (0 bytes)

Stats

  • Started 2024-07-23T23:32:59
  • Finished 2024-07-23T23:33:00
  • Duration

AST

nnkStmtList.newTree(
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("EventHandler"),
      newEmptyNode(),
      nnkProcTy.newTree(
        nnkFormalParams.newTree(
          newEmptyNode(),
          nnkIdentDefs.newTree(
            newIdentNode("target"),
            newIdentNode("BB"),
            newEmptyNode()
          )
        ),
        newEmptyNode()
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("BB"),
      newEmptyNode(),
      nnkTupleConstr.newTree(
        newIdentNode("EventHandler")
      )
    )
  )
)
2.0.0 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

IR

Compiled filesize 0 (0 bytes)

Stats

  • Started 2024-07-23T23:33:03
  • Finished 2024-07-23T23:33:03
  • Duration

AST

nnkStmtList.newTree(
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("EventHandler"),
      newEmptyNode(),
      nnkProcTy.newTree(
        nnkFormalParams.newTree(
          newEmptyNode(),
          nnkIdentDefs.newTree(
            newIdentNode("target"),
            newIdentNode("BB"),
            newEmptyNode()
          )
        ),
        newEmptyNode()
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("BB"),
      newEmptyNode(),
      nnkTupleConstr.newTree(
        newIdentNode("EventHandler")
      )
    )
  )
)
1.6.20 👎 FAIL

Output

Error: Command failed: nim c --run  -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

IR

Compiled filesize 0 (0 bytes)

Stats

  • Started 2024-07-23T23:33:06
  • Finished 2024-07-23T23:33:06
  • Duration

AST

nnkStmtList.newTree(
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("EventHandler"),
      newEmptyNode(),
      nnkProcTy.newTree(
        nnkFormalParams.newTree(
          newEmptyNode(),
          nnkIdentDefs.newTree(
            newIdentNode("target"),
            newIdentNode("BB"),
            newEmptyNode()
          )
        ),
        newEmptyNode()
      )
    ),
    nnkTypeDef.newTree(
      newIdentNode("BB"),
      newEmptyNode(),
      nnkTupleConstr.newTree(
        newIdentNode("EventHandler")
      )
    )
  )
)
1.4.8 👍 OK

Output


IR

Compiled filesize 91.16 Kb (93,344 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#define nimfr_(x, y)
#define nimln_(x, y)
static N_INLINE(void, initStackBottomWith)(void* locals);
N_LIB_PRIVATE N_NOINLINE(void, nimGC_setStackBottom)(void* theStackBottom);
N_LIB_PRIVATE N_NIMCALL(void, systemDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
static N_INLINE(void, initStackBottomWith)(void* locals) {
 nimGC_setStackBottom(locals);
}
N_LIB_PRIVATE void PreMainInner(void) {
}
N_LIB_PRIVATE int cmdCount;
N_LIB_PRIVATE char** cmdLine;
N_LIB_PRIVATE char** gEnv;
N_LIB_PRIVATE void PreMain(void) {
 void (*volatile inner)(void);
 inner = PreMainInner;
 systemDatInit000();
 initStackBottomWith((void *)&inner);
 systemInit000();
 (*inner)();
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
 NimMainModule();
}
N_CDECL(void, NimMain)(void) {
 void (*volatile inner)(void);
 PreMain();
 inner = NimMainInner;
 initStackBottomWith((void *)&inner);
 (*inner)();
}
int main(int argc, char** args, char** env) {
 cmdLine = args;
 cmdCount = argc;
 gEnv = env;
 NimMain();
 return nim_program_result;
}
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) {
{
}
}

Stats

  • Started 2024-07-23T23:33:09
  • Finished 2024-07-23T23:33:09
  • Duration
1.2.18 👍 OK

Output


IR

Compiled filesize 86.88 Kb (88,968 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#define nimfr_(x, y)
#define nimln_(x, y)
static N_INLINE(void, initStackBottomWith)(void* locals);
N_LIB_PRIVATE N_NOINLINE(void, nimGC_setStackBottom)(void* theStackBottom);
N_LIB_PRIVATE N_NIMCALL(void, systemDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
static N_INLINE(void, initStackBottomWith)(void* locals) {
 nimGC_setStackBottom(locals);
}
N_LIB_PRIVATE void PreMainInner(void) {
}
N_LIB_PRIVATE int cmdCount;
N_LIB_PRIVATE char** cmdLine;
N_LIB_PRIVATE char** gEnv;
N_LIB_PRIVATE void PreMain(void) {
 void (*volatile inner)(void);
 inner = PreMainInner;
 systemDatInit000();
 initStackBottomWith((void *)&inner);
 systemInit000();
 (*inner)();
}
N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) {
 NimMainModule();
}
N_CDECL(void, NimMain)(void) {
 void (*volatile inner)(void);
 PreMain();
 inner = NimMainInner;
 initStackBottomWith((void *)&inner);
 (*inner)();
}
int main(int argc, char** args, char** env) {
 cmdLine = args;
 cmdCount = argc;
 gEnv = env;
 NimMain();
 return nim_program_result;
}
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) {
{
}
}

Stats

  • Started 2024-07-23T23:33:11
  • Finished 2024-07-23T23:33:12
  • Duration
1.0.10 👍 OK

Output


IR

Compiled filesize 81.98 Kb (83,952 bytes)
#define NIM_INTBITS 64
#include "nimbase.h"
#define nimfr_(x, y)
#define nimln_(x, y)
static N_INLINE(void, initStackBottomWith)(void* locals);
N_NOINLINE(void, nimGC_setStackBottom)(void* theStackBottom);
N_LIB_PRIVATE N_NIMCALL(void, systemDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
static N_INLINE(void, initStackBottomWith)(void* locals) {	nimGC_setStackBottom(locals);
}
void PreMainInner(void) {
}
int cmdCount;
char** cmdLine;
char** gEnv;
void PreMain(void) {
 void (*volatile inner)(void);
 inner = PreMainInner;
 systemDatInit000();
 initStackBottomWith((void *)&inner);
 systemInit000();
 (*inner)();
}
N_CDECL(void, NimMainInner)(void) {
 NimMainModule();
}
N_CDECL(void, NimMain)(void) {
 void (*volatile inner)(void);
 PreMain();
 inner = NimMainInner;
 initStackBottomWith((void *)&inner);
 (*inner)();
}
int main(int argc, char** args, char** env) {
 cmdLine = args;
 cmdCount = argc;
 gEnv = env;
 NimMain();
 return nim_program_result;
}
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) {
{
}
}

Stats

  • Started 2024-07-23T23:33:13
  • Finished 2024-07-23T23:33:14
  • Duration
#0286a0879 ➡️ 🐛

Diagnostics

cooldome introduced a bug at 2021-01-11 09:09:38 +0000 on commit #0286a0879 with message:

fix #16651 (#16658)

* fix #16651

The bug is in the files:

compiler/semtypes.nim
tests/converter/tgenericconverter.nim

The bug can be in the commits:

(Diagnostics sometimes off-by-one).

Stats
  • GCC 11.4.0
  • Clang 14.0.0
  • NodeJS 20.4
  • Created 2024-07-23T23:32:11Z
  • Comments 2
  • Commands nim c --run -d:nimDebug -d:nimDebugDlOpen -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

🤖 Bug found in 53 minutes bisecting 4175 commits at 79 commits per second

@juancarlospaco
Copy link
Collaborator

@Graveflo see #23885 (comment) looks like #16658 is the cause...

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