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

Regression from 1.6 to 2.0/devel with nim c -c SIGSEGV with template/raises: [] #22284

Closed
tersec opened this issue Jul 14, 2023 · 6 comments · Fixed by #23368
Closed

Regression from 1.6 to 2.0/devel with nim c -c SIGSEGV with template/raises: [] #22284

tersec opened this issue Jul 14, 2023 · 6 comments · Fixed by #23368

Comments

@tersec
Copy link
Contributor

tersec commented Jul 14, 2023

Description

import std/macros

macro h(): untyped =
  result = newTree(nnkStmtList)
  result.add quote do:
    new int

type F = object

proc j[SecondarySources](
    uRef: ref SecondarySources,
    u: proc (config: F, sources: ref SecondarySources)): F =
  u(result, uRef)

template programMain(body: untyped) =
  proc main {.raises: [].} = body  # doesn't SIGSEGV without this {.raises: [].}
  main()

programMain:
  var uRef = h()
  discard j(uRef, u = proc(config: F, sources: auto) {.raises: [].} = discard)

Nim 1.6 compiles and Nim 2.0/devel SIGSEGV when attempting to compile it. refc/ORC doesn't change results.

Nim Version

Nim Compiler Version 1.6.15 [Linux: amd64]
Compiled at 2023-07-14
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: 1cd48e4b2abd867adf1ab52a70a1d8f1c6ac77c4
active boot switches: -d:release
Nim Compiler Version 2.0.0 [Linux: amd64]
Compiled at 2023-07-13
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: a9cf99270765dc806568aca93d0f2d59afda3491
active boot switches: -d:release
Nim Compiler Version 1.9.5 [Linux: amd64]
Compiled at 2023-07-14
Copyright (c) 2006-2023 by Andreas Rumpf

git hash: f9280090f623d8fddbf753ec50e0ecd21f388d00
active boot switches: -d:release

Current Output

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

Expected Output

No SIGSEGV with nim c -c

Possible Solution

No response

Additional Information

No response

@ringabout
Copy link
Member

!nim c --gc:arc

import std/macros

macro h(): untyped =
  result = newTree(nnkStmtList)
  result.add quote do:
    new int

type F = object

proc j[SecondarySources](
    uRef: ref SecondarySources,
    u: proc (config: F, sources: ref SecondarySources)): F =
  u(result, uRef)

template programMain(body: untyped) =
  proc main {.raises: [].} = body  # doesn't SIGSEGV without this {.raises: [].}
  main()

programMain:
  var uRef = h()
  discard j(uRef, u = proc(config: F, sources: auto) {.raises: [].} = discard)

@github-actions
Copy link
Contributor

@ringabout (member)

devel :-1: FAIL

Output

Error: Command failed: nim c --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off  --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
command line(1, 2) Warning: `gc:option` is deprecated; use `mm:option` instead [Deprecated]
SIGSEGV: Illegal storage access. (Attempt to read from nil?)

Stats

  • Created 2023-07-15T01:52:27Z
  • Started 2023-07-15T01:52:58
  • Finished 2023-07-15T01:52:58
  • Duration 1 minute
  • Commands nim c --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

IR

Filesize 0 bytes

AST

stable :+1: OK

Output


Stats

  • Created 2023-07-15T01:52:27Z
  • Started 2023-07-15T01:52:59
  • Finished 2023-07-15T01:53:00
  • Duration 1 minute
  • Commands nim c --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
1.6.0 :+1: OK

Output


Stats

  • Created 2023-07-15T01:52:27Z
  • Started 2023-07-15T01:53:02
  • Finished 2023-07-15T01:53:03
  • Duration 1 minute
  • Commands nim c --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
1.4.0 :+1: OK

Output


Stats

  • Created 2023-07-15T01:52:27Z
  • Started 2023-07-15T01:53:05
  • Finished 2023-07-15T01:53:06
  • Duration now
  • Commands nim c --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
1.2.0 :+1: OK

Output


Stats

  • Created 2023-07-15T01:52:27Z
  • Started 2023-07-15T01:53:21
  • Finished 2023-07-15T01:53:22
  • Duration now
  • Commands nim c --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
1.0.0 :-1: FAIL

Output

Error: Command failed: nim c --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off  --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
command line(1, 2) Error: 'none', 'boehm' or 'refc' expected, but 'arc' found

Stats

  • Created 2023-07-15T01:52:27Z
  • Started 2023-07-15T01:53:35
  • Finished 2023-07-15T01:53:35
  • Duration now
  • Commands nim c --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

IR

Filesize 72.77 Kb
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix
  #  define nimfr_(proc, file) \
      TFrame FR_; \
      FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
  #  define nimfrs_(proc, file, slots, length) \
      struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename; NI len; VarSlot s[slots];} FR_; \
      FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
  #  define nimln_(n, file) \
      FR_.line = n; FR_.filename = file;
  typedef struct tyObject_F__14lYh4oluwdYz4t36O2xQw tyObject_F__14lYh4oluwdYz4t36O2xQw;
struct tyObject_F__14lYh4oluwdYz4t36O2xQw {
char dummy;
};
typedef struct {
N_NIMCALL_PTR(void, ClP_0) (tyObject_F__14lYh4oluwdYz4t36O2xQw config, NI* sources, void* ClE_0);
void* ClE_0;
} tyProc__LZLuoUR7AaT0ACVfBEK6Dw;
typedef N_CLOSURE_PTR(void, TM__SRd76hP9cMfCzdUO857UhQQ_2) (tyObject_F__14lYh4oluwdYz4t36O2xQw config, NI* sources);
typedef N_CLOSURE_PTR(void, TM__SRd76hP9cMfCzdUO857UhQQ_3) (tyObject_F__14lYh4oluwdYz4t36O2xQw config, NI* sources, void* ClE_0);
N_LIB_PRIVATE N_NIMCALL(void, main__EzBZaa239as9bFx8yeHDoTOw)(void);
N_LIB_PRIVATE N_NIMCALL(NI*, new__wSSF51wLRD8g2UFxfG6Hvg)(void);
N_LIB_PRIVATE N_NIMCALL(tyObject_F__14lYh4oluwdYz4t36O2xQw, j__iTAQnwn3njnNlgstaPAiBg)(NI* uRef, tyProc__LZLuoUR7AaT0ACVfBEK6Dw u);
static N_INLINE(void, nimZeroMem)(void* p, NI size);
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
static N_INLINE(void, nimFrame)(TFrame* s);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__mMRdr4sgmnykA9aWeM9aDZlw)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(void, colonanonymous___EaAvPQyx3WKJ4QgVUyHQDQ)(tyObject_F__14lYh4oluwdYz4t36O2xQw config, NI* sources);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___1W4b9ba7JmVflmV3cQesuiA)(NI** dest);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
static N_INLINE(void, initStackBottomWith)(void* locals);
N_LIB_PRIVATE N_NIMCALL(void, systemDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
extern NIM_BOOL nimInErrorMode__759bT87luu8XGcbkw13FUjA;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size) {
	void* T1_;
	T1_ = (void*)0;
	T1_ = memset(a, v, ((size_t) (size)));
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
	NIM_BOOL* result;
	result = (NIM_BOOL*)0;
	result = (&nimInErrorMode__759bT87luu8XGcbkw13FUjA);
	return result;
}
static N_INLINE(void, nimZeroMem)(void* p, NI size) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory(p, ((int) 0), size);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
}
static N_INLINE(void, nimFrame)(TFrame* s) {
	{
		if (!(framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw == NIM_NIL)) goto LA3_;
		(*s).calldepth = ((NI16) 0);
	}
	goto LA1_;
	LA3_: ;
	{
		(*s).calldepth = (NI16)((*framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw).calldepth + ((NI16) 1));
	}
	LA1_: ;
	(*s).prev = framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
	framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw = s;
	{
		if (!((*s).calldepth == ((NI16) (((NI) 2000))))) goto LA8_;
		callDepthLimitReached__mMRdr4sgmnykA9aWeM9aDZlw();
	}
	LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
	framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw = (*framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw).prev;
}
N_LIB_PRIVATE N_NIMCALL(tyObject_F__14lYh4oluwdYz4t36O2xQw, j__iTAQnwn3njnNlgstaPAiBg)(NI* uRef, tyProc__LZLuoUR7AaT0ACVfBEK6Dw u) {
	tyObject_F__14lYh4oluwdYz4t36O2xQw result;
NIM_BOOL* nimErr_;
	nimfr_("j", "/home/runner/work/Nim/Nim/temp.nim");
{nimErr_ = nimErrorFlag();
	nimZeroMem((void*)(&result), sizeof(tyObject_F__14lYh4oluwdYz4t36O2xQw));
	u.ClE_0? u.ClP_0(result, uRef, u.ClE_0):((TM__SRd76hP9cMfCzdUO857UhQQ_2)(u.ClP_0))(result, uRef);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
	popFrame();
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, colonanonymous___EaAvPQyx3WKJ4QgVUyHQDQ)(tyObject_F__14lYh4oluwdYz4t36O2xQw config, NI* sources) {
	nimfr_(":anonymous", "/home/runner/work/Nim/Nim/temp.nim");
	popFrame();
}
N_LIB_PRIVATE N_NIMCALL(void, main__EzBZaa239as9bFx8yeHDoTOw)(void) {
	NI* uRef;
	tyProc__LZLuoUR7AaT0ACVfBEK6Dw T2_;
	tyObject_F__14lYh4oluwdYz4t36O2xQw T3_;
NIM_BOOL* nimErr_;
	nimfr_("main", "/home/runner/work/Nim/Nim/temp.nim");
{nimErr_ = nimErrorFlag();
	uRef = (NI*)0;
	uRef = new__wSSF51wLRD8g2UFxfG6Hvg();
	nimZeroMem((void*)(&T2_), sizeof(tyProc__LZLuoUR7AaT0ACVfBEK6Dw));
	T2_.ClP_0 = ((TM__SRd76hP9cMfCzdUO857UhQQ_3) (colonanonymous___EaAvPQyx3WKJ4QgVUyHQDQ)); T2_.ClE_0 = NIM_NIL;
	T3_ = j__iTAQnwn3njnNlgstaPAiBg(uRef, T2_);
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	(void)(T3_);
	{
		LA1_:;
	}
	{
		eqdestroy___1W4b9ba7JmVflmV3cQesuiA(&uRef);
	}
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
	popFrame();
}
static N_INLINE(void, initStackBottomWith)(void* 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) {
{
NIM_BOOL* nimErr_;
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
	main__EzBZaa239as9bFx8yeHDoTOw();
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	BeforeRet_: ;
	nimTestErrorFlag();
	popFrame();
}
}

AST

0.20.2 :-1: FAIL

Output

Error: Command failed: nim c --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off  --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim
command line(1, 2) Error: 'none', 'boehm' or 'refc' expected, but 'arc' found

Stats

  • Created 2023-07-15T01:52:27Z
  • Started 2023-07-15T01:53:46
  • Finished 2023-07-15T01:53:46
  • Duration now
  • Commands nim c --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --verbosity:0 --hints:off --warnings:off --lineTrace:off --nimcache:/home/runner/work/Nim/Nim --out:/home/runner/work/Nim/Nim/temp /home/runner/work/Nim/Nim/temp.nim

IR

Filesize 72.77 Kb
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix
  #  define nimfr_(proc, file) \
      TFrame FR_; \
      FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = 0; nimFrame(&FR_);
  #  define nimfrs_(proc, file, slots, length) \
      struct {TFrame* prev;NCSTRING procname;NI line;NCSTRING filename; NI len; VarSlot s[slots];} FR_; \
      FR_.procname = proc; FR_.filename = file; FR_.line = 0; FR_.len = length; nimFrame((TFrame*)&FR_);
  #  define nimln_(n, file) \
      FR_.line = n; FR_.filename = file;
  typedef struct tyObject_F__14lYh4oluwdYz4t36O2xQw tyObject_F__14lYh4oluwdYz4t36O2xQw;
struct tyObject_F__14lYh4oluwdYz4t36O2xQw {
char dummy;
};
typedef struct {
N_NIMCALL_PTR(void, ClP_0) (tyObject_F__14lYh4oluwdYz4t36O2xQw config, NI* sources, void* ClE_0);
void* ClE_0;
} tyProc__LZLuoUR7AaT0ACVfBEK6Dw;
typedef N_CLOSURE_PTR(void, TM__SRd76hP9cMfCzdUO857UhQQ_2) (tyObject_F__14lYh4oluwdYz4t36O2xQw config, NI* sources);
typedef N_CLOSURE_PTR(void, TM__SRd76hP9cMfCzdUO857UhQQ_3) (tyObject_F__14lYh4oluwdYz4t36O2xQw config, NI* sources, void* ClE_0);
N_LIB_PRIVATE N_NIMCALL(void, main__EzBZaa239as9bFx8yeHDoTOw)(void);
N_LIB_PRIVATE N_NIMCALL(NI*, new__wSSF51wLRD8g2UFxfG6Hvg)(void);
N_LIB_PRIVATE N_NIMCALL(tyObject_F__14lYh4oluwdYz4t36O2xQw, j__iTAQnwn3njnNlgstaPAiBg)(NI* uRef, tyProc__LZLuoUR7AaT0ACVfBEK6Dw u);
static N_INLINE(void, nimZeroMem)(void* p, NI size);
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
static N_INLINE(void, nimFrame)(TFrame* s);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached__mMRdr4sgmnykA9aWeM9aDZlw)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(void, colonanonymous___EaAvPQyx3WKJ4QgVUyHQDQ)(tyObject_F__14lYh4oluwdYz4t36O2xQw config, NI* sources);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___1W4b9ba7JmVflmV3cQesuiA)(NI** dest);
N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void);
static N_INLINE(void, initStackBottomWith)(void* locals);
N_LIB_PRIVATE N_NIMCALL(void, systemDatInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, systemInit000)(void);
N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void);
extern NIM_BOOL nimInErrorMode__759bT87luu8XGcbkw13FUjA;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
extern TFrame* framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size) {
	void* T1_;
	T1_ = (void*)0;
	T1_ = memset(a, v, ((size_t) (size)));
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
	NIM_BOOL* result;
	result = (NIM_BOOL*)0;
	result = (&nimInErrorMode__759bT87luu8XGcbkw13FUjA);
	return result;
}
static N_INLINE(void, nimZeroMem)(void* p, NI size) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory(p, ((int) 0), size);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
}
static N_INLINE(void, nimFrame)(TFrame* s) {
	{
		if (!(framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw == NIM_NIL)) goto LA3_;
		(*s).calldepth = ((NI16) 0);
	}
	goto LA1_;
	LA3_: ;
	{
		(*s).calldepth = (NI16)((*framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw).calldepth + ((NI16) 1));
	}
	LA1_: ;
	(*s).prev = framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw;
	framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw = s;
	{
		if (!((*s).calldepth == ((NI16) (((NI) 2000))))) goto LA8_;
		callDepthLimitReached__mMRdr4sgmnykA9aWeM9aDZlw();
	}
	LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
	framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw = (*framePtr__HRfVMH3jYeBJz6Q6X9b6Ptw).prev;
}
N_LIB_PRIVATE N_NIMCALL(tyObject_F__14lYh4oluwdYz4t36O2xQw, j__iTAQnwn3njnNlgstaPAiBg)(NI* uRef, tyProc__LZLuoUR7AaT0ACVfBEK6Dw u) {
	tyObject_F__14lYh4oluwdYz4t36O2xQw result;
NIM_BOOL* nimErr_;
	nimfr_("j", "/home/runner/work/Nim/Nim/temp.nim");
{nimErr_ = nimErrorFlag();
	nimZeroMem((void*)(&result), sizeof(tyObject_F__14lYh4oluwdYz4t36O2xQw));
	u.ClE_0? u.ClP_0(result, uRef, u.ClE_0):((TM__SRd76hP9cMfCzdUO857UhQQ_2)(u.ClP_0))(result, uRef);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
	popFrame();
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, colonanonymous___EaAvPQyx3WKJ4QgVUyHQDQ)(tyObject_F__14lYh4oluwdYz4t36O2xQw config, NI* sources) {
	nimfr_(":anonymous", "/home/runner/work/Nim/Nim/temp.nim");
	popFrame();
}
N_LIB_PRIVATE N_NIMCALL(void, main__EzBZaa239as9bFx8yeHDoTOw)(void) {
	NI* uRef;
	tyProc__LZLuoUR7AaT0ACVfBEK6Dw T2_;
	tyObject_F__14lYh4oluwdYz4t36O2xQw T3_;
NIM_BOOL* nimErr_;
	nimfr_("main", "/home/runner/work/Nim/Nim/temp.nim");
{nimErr_ = nimErrorFlag();
	uRef = (NI*)0;
	uRef = new__wSSF51wLRD8g2UFxfG6Hvg();
	nimZeroMem((void*)(&T2_), sizeof(tyProc__LZLuoUR7AaT0ACVfBEK6Dw));
	T2_.ClP_0 = ((TM__SRd76hP9cMfCzdUO857UhQQ_3) (colonanonymous___EaAvPQyx3WKJ4QgVUyHQDQ)); T2_.ClE_0 = NIM_NIL;
	T3_ = j__iTAQnwn3njnNlgstaPAiBg(uRef, T2_);
	if (NIM_UNLIKELY(*nimErr_)) goto LA1_;
	(void)(T3_);
	{
		LA1_:;
	}
	{
		eqdestroy___1W4b9ba7JmVflmV3cQesuiA(&uRef);
	}
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
	popFrame();
}
static N_INLINE(void, initStackBottomWith)(void* 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) {
{
NIM_BOOL* nimErr_;
	nimfr_("temp", "/home/runner/work/Nim/Nim/temp.nim");
nimErr_ = nimErrorFlag();
	main__EzBZaa239as9bFx8yeHDoTOw();
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	BeforeRet_: ;
	nimTestErrorFlag();
	popFrame();
}
}

AST

#1e15f975b ➡️ 🐛

Diagnostics

ringabout introduced a bug at 2022-10-15 20:07:40 +0800 on commit #1e15f975b with message:

fixes #19162; enable `strictEffects` for v2 (#19380)

* enable stricteffects
* add gcsafe
* fix tests
* use func
* fixes pegs tests
* explicitly mark repr related procs with noSideEffect
* add nimLegacyEffects
* change URL
* fixes docopt
* add `raises: []` to repr
* fixes weave
* fixes nimyaml
* fixes glob
* fixes parsetoml
* Apply suggestions from code review
* Update testament/important_packages.nim
* add legacy:laxEffects

The bug is in the files:

changelog.md
compiler/nim.cfg
compiler/options.nim
compiler/sempass2.nim
config/config.nims
doc/manual.md
lib/pure/pegs.nim
lib/system.nim
lib/system/repr_v2.nim
nimsuggest/sexp.nim
testament/important_packages.nim
tests/closure/tnested.nim
tests/effects/teffects6.nim
tests/effects/tgcsafe.nim
tests/effects/tnosideeffect.nim
tests/stdlib/tpegs.nim

The bug can be in the commits:

(Diagnostics sometimes off-by-one).

🤖 Bug found in 43 minutes bisecting 1581 commits at 36 commits per second.

@ringabout
Copy link
Member

Related to auto: after changing auto to ref int, it raises as expected.

etan-status added a commit to status-im/nimbus-eth2 that referenced this issue Jul 19, 2023
To avoid Nim 2.0 issue nim-lang/Nim#22284,
explicitly specify `ref SecondarySources` instead of using `auto`,
and add `{.raises.}` annotation
etan-status added a commit to status-im/nimbus-eth2 that referenced this issue Jul 19, 2023
To avoid Nim 2.0 issue nim-lang/Nim#22284,
explicitly specify `ref SecondarySources` instead of using `auto`,
and add `{.raises.}` annotation
@bung87
Copy link
Collaborator

bung87 commented Jul 30, 2023

by change renderer.nim proc lcomma

if  param == nil:
      continue

get Error: j(uRef, proc (config; sources): [], {.raises: [].}, {.raises: [].} = discard ) can raise an unlisted exception: Exception

when proc checkRaisesSpec try to show message, it use renderTree(rr) while rr can't properly be represented

note: [], {.raises: [].}, {.raises: [].} looks weird.

@ringabout
Copy link
Member

It seems that lambda might lack some semchecks because moving it into a function raises as expected

@ringabout
Copy link
Member

Found the root cause

Araq pushed a commit that referenced this issue Mar 9, 2024
…erred lambdas (#23368)

fixes #22284
fixes #22282


```
Error: j(uRef, proc (config: F; sources: auto) {.raises: [].} = discard ) can raise an unlisted exception: Exception
```


The problem is that `n.typ.n` contains the effectList which shouldn't
appear in the parameter of a function defintion. We could not simply use
`n.typ.n` as `n[paramsPos]`. The effect lists should be stripped away
anyway.
heterodoxic pushed a commit to heterodoxic/Nim that referenced this issue Mar 11, 2024
…arameters of inferred lambdas (nim-lang#23368)

fixes nim-lang#22284
fixes nim-lang#22282


```
Error: j(uRef, proc (config: F; sources: auto) {.raises: [].} = discard ) can raise an unlisted exception: Exception
```


The problem is that `n.typ.n` contains the effectList which shouldn't
appear in the parameter of a function defintion. We could not simply use
`n.typ.n` as `n[paramsPos]`. The effect lists should be stripped away
anyway.
narimiran pushed a commit that referenced this issue Apr 22, 2024
…erred lambdas (#23368)

fixes #22284
fixes #22282

```
Error: j(uRef, proc (config: F; sources: auto) {.raises: [].} = discard ) can raise an unlisted exception: Exception
```

The problem is that `n.typ.n` contains the effectList which shouldn't
appear in the parameter of a function defintion. We could not simply use
`n.typ.n` as `n[paramsPos]`. The effect lists should be stripped away
anyway.

(cherry picked from commit 3203111)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants