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] Crash when adding openArray proc argument to a local seq #15511

Closed
ghost opened this issue Oct 7, 2020 · 13 comments
Closed

[ARC] Crash when adding openArray proc argument to a local seq #15511

ghost opened this issue Oct 7, 2020 · 13 comments

Comments

@ghost
Copy link

ghost commented Oct 7, 2020

Found in https://github.com/paranim/pararules. Seems to be caused by the fact that system.add uses move here?

Example

type
  Position = object
    data: seq[float]

proc test(data: openArray[float]) = 
  var pos = Position()
  pos.data.add(data)

test([1.5, 1.6])

Current Output

Traceback (most recent call last)
/home/dian/Projects/stuff/a.nim(9) a
/home/dian/Projects/stuff/a.nim(7) test
/home/dian/Things/Nim/lib/system.nim(1242) add
SIGSEGV: Illegal storage access. (Attempt to read from nil?)

Expected Output

Nothing

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

git hash: acbe27b082c202895df1b78a82951389b4a232a0
active boot switches: -d:release -d:danger
Araq added a commit that referenced this issue Oct 8, 2020
@Araq Araq closed this as completed in 538a57a Oct 8, 2020
@ghost
Copy link
Author

ghost commented Oct 8, 2020

@Araq is it correct that after this PR the compiler fails on this line https://github.com/paranim/paranim/blob/master/src/paranim/gl/entities.nim#L111 with an error
"/home/dian/.nimble/pkgs/paranim-0.9.0/paranim/gl/entities.nim(110, 23) Error: cannot create an implicit openArray copy to be passed to a sink parameter" ?

EDIT: Noticed that the test case gives the same error :)

@ghost
Copy link
Author

ghost commented Oct 8, 2020

so it means that arc/orc is a bit incompatible with refc in this case?

@Araq
Copy link
Member

Araq commented Oct 9, 2020

For now. Working on a better fix.

@timotheecour
Copy link
Member

timotheecour commented Oct 31, 2020

an error is better than SIGSEGV but this is still something that should be fixed, it makes nim-regex pkg unusable with --gc:arc
see nitely/nim-regex#81
and who knows what other code

further reduced:

when true: # D20201031T170455
  proc fn(a: openArray[int]) =
    var b: seq[int]
    b.add a
  fn(@[1,2])

gives Error: cannot create an implicit openArray copy to be passed to a sink parameter (since the above PR that removes the SIGSEGV), but this should work

proposal

# in system.nim
proc add*[T](x: var seq[T], y: sink openArray[T]) {.noSideEffect.} {.enableIf: canSink(y)).} =
  ...
  x[xl+i] = move y[i]
proc add*[T](x: var seq[T], y: openArray[T]) {.noSideEffect.} {.enableIf: not canSink(y).} =
  ...
  x[xl+i] = y[i]

canSink can be implemented in different ways, for eg:

proc canSinkImpl[T](y: sink openArray[T]) = discard
template canSink(a): untyped = compiles(canSinkImpl(y))

or without compiles using overloadExists, which is cheaper, via #12076

@Araq
Copy link
Member

Araq commented Nov 2, 2020

The fix that I have in mind is to implement the alias analysis to prevent the bug and keep the system.nim's add a non-sink parameter as sink openArray[T] is a misguided construct, an openArray is a view-type, it never owns and sink always owns. A contradiction.

@timotheecour
Copy link
Member

sink openArray[T] is a misguided construct, an openArray is a view-type, it never owns

but then you'll have to duplicate each proc accepting a sink parameter with y: openArray[T], y: sink seq[T] overload to avoid copies when the whole container can be sinked, eg a seq or array;

Also, it's not clear how that'd work with array's (we don't want to generate code bloat by being generic on array size), eg:

var s = @[A(1), A(2)]
s.add [A(3), A(4)] # I want to move, not copy, A(3), A(4)

The problem is that openArray loses some type information: whether original container can be passed to a sink.
There must be a better way.

@Araq
Copy link
Member

Araq commented Nov 2, 2020

Well yes, it's complex.

@cooldome
Copy link
Member

cooldome commented Nov 5, 2020

Possibly we need:

proc add*[T](x: var seq[T], y: sink (seq[T] | array[any, T]))

We can have a common type name alias for seq[T] | array[any, T])
I know array[any, T] doesn't work for now, but we can make it work.

P.S.
varargs remains one question

@cooldome
Copy link
Member

cooldome commented Nov 5, 2020

Actually this may work, 2 procs:

proc add*[T](x: var seq[T], y: sink (seq[T] | array[any, T]))
proc add*[T](x: var seq[T], y: openarray[T])

and make sink to match better.
Copy to opennarray/varargs to seq sounds easier though.

@timotheecour
Copy link
Member

proc add*[T](x: var seq[T], y: sink (seq[T] | array[any, T])) generates code bloat (1 instantiation per array size)

the solution I suggested in #15511 (comment) doesn't have this problem.

mildred pushed a commit to mildred/Nim that referenced this issue Jan 11, 2021
@Araq
Copy link
Member

Araq commented Feb 24, 2021

Has been fixed.

@Araq Araq closed this as completed Feb 24, 2021
timotheecour added a commit to timotheecour/nim-regex that referenced this issue Feb 25, 2021
nitely pushed a commit to nitely/nim-regex that referenced this issue Mar 21, 2021
* followup now that nim-lang/Nim#15511 was fixed

* simplify via toSeq

* avoid warning: IndexError is deprecated

* drop support for nim < 1.0 which broke tests
@ringabout
Copy link
Member

!nim c --gc:arc

type
  Position = object
    data: seq[float]

proc test(data: openArray[float]) = 
  var pos = Position()
  pos.data.add(data)

test([1.5, 1.6])

@github-actions
Copy link
Contributor

github-actions bot commented Jul 5, 2023

@ringabout (member)

devel :+1: OK

Output


Stats

  • Created 2023-07-05T05:54:10Z
  • Started 2023-07-05T05:54:50
  • Finished 2023-07-05T05:54:50
  • Duration 1 minute
  • Commands nim c --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads: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
stable :+1: OK

Output


Stats

  • Created 2023-07-05T05:54:10Z
  • Started 2023-07-05T05:54:51
  • Finished 2023-07-05T05:54:51
  • Duration 1 minute
  • Commands nim c --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads: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-05T05:54:10Z
  • Started 2023-07-05T05:54:54
  • Finished 2023-07-05T05:54:55
  • Duration 1 minute
  • Commands nim c --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads: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: FAIL

Output

Error: Command failed: nim c --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads: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
/home/runner/work/Nim/Nim/temp.nim(7, 16) Error: cannot create an implicit openArray copy to be passed to a sink parameter

Stats

  • Created 2023-07-05T05:54:10Z
  • Started 2023-07-05T05:54:59
  • Finished 2023-07-05T05:54:59
  • Duration now
  • Commands nim c --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads: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

#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_Position__9bSg74cbDWcz9agKwF8Zm5FQ tyObject_Position__9bSg74cbDWcz9agKwF8Zm5FQ;
typedef struct tySequence__Zj5xKXgsXnI4n4hPS6nACA tySequence__Zj5xKXgsXnI4n4hPS6nACA;
typedef struct tySequence__Zj5xKXgsXnI4n4hPS6nACA_Content tySequence__Zj5xKXgsXnI4n4hPS6nACA_Content;
typedef struct tyObject_NimSeqV2__gGGdEGA2get5XTHGxBt1eQ tyObject_NimSeqV2__gGGdEGA2get5XTHGxBt1eQ;
typedef struct tyObject_NimSeqPayload__y3DXUXET6vJbnpJP9bxHp6g tyObject_NimSeqPayload__y3DXUXET6vJbnpJP9bxHp6g;
struct tySequence__Zj5xKXgsXnI4n4hPS6nACA {
  NI len; tySequence__Zj5xKXgsXnI4n4hPS6nACA_Content* p;
};
struct tyObject_Position__9bSg74cbDWcz9agKwF8Zm5FQ {
tySequence__Zj5xKXgsXnI4n4hPS6nACA data;
};
struct tyObject_NimSeqV2__gGGdEGA2get5XTHGxBt1eQ {
NI len;
tyObject_NimSeqPayload__y3DXUXET6vJbnpJP9bxHp6g* p;
};
struct tyObject_NimSeqPayload__y3DXUXET6vJbnpJP9bxHp6g {
NI cap;
NF data[SEQ_DECL_SIZE];
};
typedef NF tyArray__Tgy9b6R4KdSrcLohzVAUl8w[2];
#ifndef tySequence__Zj5xKXgsXnI4n4hPS6nACA_Content_PP
#define tySequence__Zj5xKXgsXnI4n4hPS6nACA_Content_PP
struct tySequence__Zj5xKXgsXnI4n4hPS6nACA_Content { NI cap; NF data[SEQ_DECL_SIZE];};
#endif
#ifndef tySequence__Zj5xKXgsXnI4n4hPS6nACA_Content_PP
#define tySequence__Zj5xKXgsXnI4n4hPS6nACA_Content_PP
struct tySequence__Zj5xKXgsXnI4n4hPS6nACA_Content { NI cap; NF data[SEQ_DECL_SIZE];};
#endif
      N_LIB_PRIVATE N_NIMCALL(void, test_temp_3)(NF* data, NI dataLen_0);
static N_INLINE(void, nimZeroMem)(void* p, NI size);
static N_INLINE(void, nimSetMem_systemZmemory_7)(void* a, int v, NI size);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, add_temp_6)(tySequence__Zj5xKXgsXnI4n4hPS6nACA* x, NF* y, NI yLen_0);
N_LIB_PRIVATE N_NIMCALL(void, setLen_temp_19)(tySequence__Zj5xKXgsXnI4n4hPS6nACA* s, NI newlen);
N_LIB_PRIVATE N_NIMCALL(void, shrink_temp_26)(tySequence__Zj5xKXgsXnI4n4hPS6nACA* x, NI newLen);
N_LIB_PRIVATE N_NIMCALL(void*, prepareSeqAdd)(NI len, void* p, NI addlen, NI elemSize, NI elemAlign);
N_LIB_PRIVATE N_NOINLINE(void, raiseOverflow)(void);
N_LIB_PRIVATE N_NOINLINE(void, raiseRangeErrorI)(NI64 i, NI64 a, NI64 b);
N_LIB_PRIVATE N_NOINLINE(void, raiseIndexError2)(NI i, NI n);
static N_INLINE(void, nimFrame)(TFrame* s);
N_LIB_PRIVATE N_NOINLINE(void, callDepthLimitReached_system_3605)(void);
static N_INLINE(void, popFrame)(void);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy__temp_93)(tyObject_Position__9bSg74cbDWcz9agKwF8Zm5FQ* dest);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy__temp_102)(tySequence__Zj5xKXgsXnI4n4hPS6nACA* dest);
N_LIB_PRIVATE N_NIMCALL(void, alignedDealloc)(void* p, NI align);
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);
static NIM_CONST tyArray__Tgy9b6R4KdSrcLohzVAUl8w TM__SRd76hP9cMfCzdUO857UhQQ_6 = {1.5,
1.6}
;
extern NIM_BOOL nimInErrorMode_system_3460;
extern TFrame* framePtr_system_3135;
extern TFrame* framePtr_system_3135;
extern TFrame* framePtr_system_3135;
extern TFrame* framePtr_system_3135;
extern TFrame* framePtr_system_3135;
extern TFrame* framePtr_system_3135;
static N_INLINE(void, nimSetMem_systemZmemory_7)(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_system_3460);
	return result;
}
static N_INLINE(void, nimZeroMem)(void* p, NI size) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	nimSetMem_systemZmemory_7(p, ((int) 0), size);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(void, shrink_temp_26)(tySequence__Zj5xKXgsXnI4n4hPS6nACA* x, NI newLen) {
	(*((tyObject_NimSeqV2__gGGdEGA2get5XTHGxBt1eQ*) (x))).len = ((NI) (newLen));
}
N_LIB_PRIVATE N_NIMCALL(void, setLen_temp_19)(tySequence__Zj5xKXgsXnI4n4hPS6nACA* s, NI newlen) {
{	{
		NI T3_;
		T3_ = (*s).len;
		if (!(((NI) (newlen)) < T3_)) goto LA4_;
		shrink_temp_26(s, newlen);
	}
	goto LA1_;
	LA4_: ;
	{
		NI oldLen;
		NI T7_;
		tyObject_NimSeqV2__gGGdEGA2get5XTHGxBt1eQ* xu;
		T7_ = (*s).len;
		oldLen = T7_;
		{
			if (!(((NI) (newlen)) <= oldLen)) goto LA10_;
			goto BeforeRet_;
		}
		LA10_: ;
		xu = ((tyObject_NimSeqV2__gGGdEGA2get5XTHGxBt1eQ*) (s));
		{
			NIM_BOOL T14_;
			NI TM__SRd76hP9cMfCzdUO857UhQQ_2;
			void* T18_;
			T14_ = (NIM_BOOL)0;
			T14_ = ((*xu).p == ((tyObject_NimSeqPayload__y3DXUXET6vJbnpJP9bxHp6g*) NIM_NIL));
			if (T14_) goto LA15_;
			T14_ = ((*(*xu).p).cap < ((NI) (newlen)));
			LA15_: ;
			if (!T14_) goto LA16_;
			if (nimSubInt(((NI) (newlen)), oldLen, &TM__SRd76hP9cMfCzdUO857UhQQ_2)) { raiseOverflow(); goto BeforeRet_;
};
			T18_ = (void*)0;
			T18_ = prepareSeqAdd(oldLen, ((void*) ((*xu).p)), (NI)(TM__SRd76hP9cMfCzdUO857UhQQ_2), ((NI) 8), ((NI) 8));
			(*xu).p = ((tyObject_NimSeqPayload__y3DXUXET6vJbnpJP9bxHp6g*) (T18_));
		}
		LA16_: ;
		(*xu).len = ((NI) (newlen));
	}
	LA1_: ;
	}BeforeRet_: ;
}
static N_INLINE(void, nimFrame)(TFrame* s) {
	{
		if (!(framePtr_system_3135 == ((TFrame*) NIM_NIL))) goto LA3_;
		(*s).calldepth = ((NI16) 0);
	}
	goto LA1_;
	LA3_: ;
	{
		(*s).calldepth = (NI16)((*framePtr_system_3135).calldepth + ((NI16) 1));
	}
	LA1_: ;
	(*s).prev = framePtr_system_3135;
	framePtr_system_3135 = s;
	{
		if (!((*s).calldepth == ((NI16) 2000))) goto LA8_;
		callDepthLimitReached_system_3605();
	}
	LA8_: ;
}
static N_INLINE(void, popFrame)(void) {
	framePtr_system_3135 = (*framePtr_system_3135).prev;
}
N_LIB_PRIVATE N_NIMCALL(void, add_temp_6)(tySequence__Zj5xKXgsXnI4n4hPS6nACA* x, NF* y, NI yLen_0) {
	NI xl;
	NI T1_;
	NI TM__SRd76hP9cMfCzdUO857UhQQ_3;
	nimfr_("add", "/home/runner/.choosenim/toolchains/nim-1.6.0/lib/system.nim");
{	T1_ = (*x).len;
	xl = T1_;
	if (nimAddInt(xl, yLen_0, &TM__SRd76hP9cMfCzdUO857UhQQ_3)) { raiseOverflow(); goto BeforeRet_;
};
	if (((NI)(TM__SRd76hP9cMfCzdUO857UhQQ_3)) < ((NI) 0) || ((NI)(TM__SRd76hP9cMfCzdUO857UhQQ_3)) > ((NI) IL64(9223372036854775807))){ raiseRangeErrorI((NI)(TM__SRd76hP9cMfCzdUO857UhQQ_3), ((NI) 0), ((NI) IL64(9223372036854775807))); goto BeforeRet_;
}
	setLen_temp_19((&(*x)), ((NI) ((NI)(TM__SRd76hP9cMfCzdUO857UhQQ_3))));
	{
		NI i;
		NI colontmp_;
		NI res;
		i = (NI)0;
		colontmp_ = (NI)0;
		colontmp_ = (yLen_0-1);
		res = ((NI) 0);
		{
			while (1) {
				NI TM__SRd76hP9cMfCzdUO857UhQQ_4;
				NI TM__SRd76hP9cMfCzdUO857UhQQ_5;
				if (!(res <= colontmp_)) goto LA4;
				i = res;
				if (nimAddInt(xl, i, &TM__SRd76hP9cMfCzdUO857UhQQ_4)) { raiseOverflow(); goto BeforeRet_;
};
				if ((NU)((NI)(TM__SRd76hP9cMfCzdUO857UhQQ_4)) >= (NU)(*x).len){ raiseIndexError2((NI)(TM__SRd76hP9cMfCzdUO857UhQQ_4),(*x).len-1); goto BeforeRet_;
}
				if ((NU)(i) >= (NU)(yLen_0)){ raiseIndexError2(i,yLen_0-1); goto BeforeRet_;
}
				(*x).p->data[(NI)(TM__SRd76hP9cMfCzdUO857UhQQ_4)] = y[i];
				if (nimAddInt(res, ((NI) 1), &TM__SRd76hP9cMfCzdUO857UhQQ_5)) { raiseOverflow(); goto BeforeRet_;
};
				res = (NI)(TM__SRd76hP9cMfCzdUO857UhQQ_5);
			} LA4: ;
		}
	}
	}BeforeRet_: ;
	popFrame();
}
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy__temp_102)(tySequence__Zj5xKXgsXnI4n4hPS6nACA* dest) {
	if ((*dest).p && !((*dest).p->cap & NIM_STRLIT_FLAG)) {
 alignedDealloc((*dest).p, NIM_ALIGNOF(NF));
}
}
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy__temp_93)(tyObject_Position__9bSg74cbDWcz9agKwF8Zm5FQ* dest) {
	eqdestroy__temp_102((&(*dest).data));
}
N_LIB_PRIVATE N_NIMCALL(void, test_temp_3)(NF* data, NI dataLen_0) {
	tyObject_Position__9bSg74cbDWcz9agKwF8Zm5FQ pos;
	nimfr_("test", "/home/runner/work/Nim/Nim/temp.nim");
	nimZeroMem((void*)(&pos), sizeof(tyObject_Position__9bSg74cbDWcz9agKwF8Zm5FQ));
	nimZeroMem((void*)(&pos), sizeof(tyObject_Position__9bSg74cbDWcz9agKwF8Zm5FQ));
	add_temp_6((&pos.data), data, dataLen_0);
	eqdestroy__temp_93((&pos));
	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();
	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();
	test_temp_3(TM__SRd76hP9cMfCzdUO857UhQQ_6, 2);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	BeforeRet_: ;
	nimTestErrorFlag();
	popFrame();
}
}

AST

nnkStmtList.newTree(
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("Position"),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("data"),
            nnkBracketExpr.newTree(
              newIdentNode("seq"),
              newIdentNode("float")
            ),
            newEmptyNode()
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("test"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("data"),
        nnkBracketExpr.newTree(
          newIdentNode("openArray"),
          newIdentNode("float")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkVarSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("pos"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("Position")
          )
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("pos"),
            newIdentNode("data")
          ),
          newIdentNode("add")
        ),
        newIdentNode("data")
      )
    )
  ),
  nnkCall.newTree(
    newIdentNode("test"),
    nnkBracket.newTree(
      newLit(1.5),
      newLit(1.6)
    )
  )
)
1.2.0 :+1: OK

Output


Stats

  • Created 2023-07-05T05:54:10Z
  • Started 2023-07-05T05:55:15
  • Finished 2023-07-05T05:55:16
  • Duration now
  • Commands nim c --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads: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 --threads: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-05T05:54:10Z
  • Started 2023-07-05T05:55:26
  • Finished 2023-07-05T05:55:26
  • Duration now
  • Commands nim c --gc:arc --run -d:strip -d:ssl -d:nimDisableCertificateValidation --forceBuild:on --colors:off --threads: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

#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_Position__9bSg74cbDWcz9agKwF8Zm5FQ tyObject_Position__9bSg74cbDWcz9agKwF8Zm5FQ;
typedef struct tySequence__Zj5xKXgsXnI4n4hPS6nACA tySequence__Zj5xKXgsXnI4n4hPS6nACA;
typedef struct tySequence__Zj5xKXgsXnI4n4hPS6nACA_Content tySequence__Zj5xKXgsXnI4n4hPS6nACA_Content;
struct tySequence__Zj5xKXgsXnI4n4hPS6nACA {
  NI len; tySequence__Zj5xKXgsXnI4n4hPS6nACA_Content* p;
};
struct tyObject_Position__9bSg74cbDWcz9agKwF8Zm5FQ {
tySequence__Zj5xKXgsXnI4n4hPS6nACA data;
};
typedef NF tyArray__Tgy9b6R4KdSrcLohzVAUl8w[2];
#ifndef tySequence__Zj5xKXgsXnI4n4hPS6nACA_Content_PP
#define tySequence__Zj5xKXgsXnI4n4hPS6nACA_Content_PP
struct tySequence__Zj5xKXgsXnI4n4hPS6nACA_Content { NI cap; NF data[SEQ_DECL_SIZE];};
#endif
#ifndef tySequence__Zj5xKXgsXnI4n4hPS6nACA_Content_PP
#define tySequence__Zj5xKXgsXnI4n4hPS6nACA_Content_PP
struct tySequence__Zj5xKXgsXnI4n4hPS6nACA_Content { NI cap; NF data[SEQ_DECL_SIZE];};
#endif
      N_LIB_PRIVATE N_NIMCALL(void, test__xFtdRlFPO9a2F29a4juFTGMw)(NF* data, NI dataLen_0);
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);
N_LIB_PRIVATE N_NOINLINE(void, chckNil)(void* p);
N_LIB_PRIVATE N_NIMCALL(void, add__fhyqOd60VIgGqZP9apBUvEg)(tySequence__Zj5xKXgsXnI4n4hPS6nACA* x, NF* y, NI yLen_0);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___BTVD8ELrrJJpUuJCqTRkOQ)(tyObject_Position__9bSg74cbDWcz9agKwF8Zm5FQ* dest);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___9c08BiLHaXt5fGmkHaCPbBQ)(tySequence__Zj5xKXgsXnI4n4hPS6nACA* dest);
N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p);
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, 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);
static NIM_CONST tyArray__Tgy9b6R4KdSrcLohzVAUl8w TM__SRd76hP9cMfCzdUO857UhQQ_2 = {1.5000000000000000e+00,
1.6000000000000001e+00}
;
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_: ;
}
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___9c08BiLHaXt5fGmkHaCPbBQ)(tySequence__Zj5xKXgsXnI4n4hPS6nACA* dest) {
	NI colontmp_;
	colontmp_ = ((NI) 0);
	{
		while (1) {
			NI T3_;
			T3_ = (*dest).len;
			if (!(colontmp_ < T3_)) goto LA2;
			colontmp_ += ((NI) 1);
		} LA2: ;
	}
	if ((*dest).p && !((*dest).p->cap & NIM_STRLIT_FLAG)) {
 deallocShared((*dest).p);
 (*dest).p = NIM_NIL; (*dest).len = 0; }
}
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___BTVD8ELrrJJpUuJCqTRkOQ)(tyObject_Position__9bSg74cbDWcz9agKwF8Zm5FQ* dest) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	eqdestroy___9c08BiLHaXt5fGmkHaCPbBQ((&(*dest).data));
	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(void, test__xFtdRlFPO9a2F29a4juFTGMw)(NF* data, NI dataLen_0) {
	tyObject_Position__9bSg74cbDWcz9agKwF8Zm5FQ pos;
NIM_BOOL oldNimErrFin1_;
NIM_BOOL* nimErr_;
	nimfr_("test", "/home/runner/work/Nim/Nim/temp.nim");
{nimErr_ = nimErrorFlag();
	nimZeroMem((void*)(&pos), sizeof(tyObject_Position__9bSg74cbDWcz9agKwF8Zm5FQ));
	chckNil((void*)(&pos));
	nimZeroMem((void*)(&pos), sizeof(tyObject_Position__9bSg74cbDWcz9agKwF8Zm5FQ));
	add__fhyqOd60VIgGqZP9apBUvEg((&pos.data), data, dataLen_0);
	{
		LA1_:;
	}
	{
		oldNimErrFin1_ = *nimErr_; *nimErr_ = NIM_FALSE;
		eqdestroy___BTVD8ELrrJJpUuJCqTRkOQ((&pos));
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		*nimErr_ = oldNimErrFin1_;
	}
	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();
	test__xFtdRlFPO9a2F29a4juFTGMw(TM__SRd76hP9cMfCzdUO857UhQQ_2, 2);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	BeforeRet_: ;
	nimTestErrorFlag();
	popFrame();
}
}

AST

nnkStmtList.newTree(
  nnkTypeSection.newTree(
    nnkTypeDef.newTree(
      newIdentNode("Position"),
      newEmptyNode(),
      nnkObjectTy.newTree(
        newEmptyNode(),
        newEmptyNode(),
        nnkRecList.newTree(
          nnkIdentDefs.newTree(
            newIdentNode("data"),
            nnkBracketExpr.newTree(
              newIdentNode("seq"),
              newIdentNode("float")
            ),
            newEmptyNode()
          )
        )
      )
    )
  ),
  nnkProcDef.newTree(
    newIdentNode("test"),
    newEmptyNode(),
    newEmptyNode(),
    nnkFormalParams.newTree(
      newEmptyNode(),
      nnkIdentDefs.newTree(
        newIdentNode("data"),
        nnkBracketExpr.newTree(
          newIdentNode("openArray"),
          newIdentNode("float")
        ),
        newEmptyNode()
      )
    ),
    newEmptyNode(),
    newEmptyNode(),
    nnkStmtList.newTree(
      nnkVarSection.newTree(
        nnkIdentDefs.newTree(
          newIdentNode("pos"),
          newEmptyNode(),
          nnkCall.newTree(
            newIdentNode("Position")
          )
        )
      ),
      nnkCall.newTree(
        nnkDotExpr.newTree(
          nnkDotExpr.newTree(
            newIdentNode("pos"),
            newIdentNode("data")
          ),
          newIdentNode("add")
        ),
        newIdentNode("data")
      )
    )
  ),
  nnkCall.newTree(
    newIdentNode("test"),
    nnkBracket.newTree(
      newLit(1.5),
      newLit(1.6)
    )
  )
)
??? ➡️ 🐛

Diagnostics

The commit that introduced the bug can not be found, but the bug is in the commits:

(Can not find the commit because Nim can not be re-built commit-by-commit to bisect).

🤖 Bug found in now bisecting 9 commits at 22 commits per second.

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

4 participants