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

Nim #head: sorting via reference hangs compiler #6724

Closed
skilchen opened this issue Nov 11, 2017 · 2 comments
Closed

Nim #head: sorting via reference hangs compiler #6724

skilchen opened this issue Nov 11, 2017 · 2 comments

Comments

@skilchen
Copy link
Contributor

skilchen commented Nov 11, 2017

The following test causes the Nim 0.17.3 compiler just cloned from github to hang. When i try nim c -r t1.nim the compilation produces an error message like:

t1.c: In function ‘test_BN7jJb30AIoqmGLz9c6zhkw’:
./nimcache/t1.c:297:51: error: ‘tyObject_Bar_jvMTkVWUjBFb12b6SKU1qg {aka > struct tyObject_Bar_jvMTkVWUjBFb12b6SKU1qg}’ has no member named ‘barLen_0’
sort_84EnBzTXl9c1maQcyvYsKBQ((*(x)).bar, ((*x)).barLen_0, T1_,
((tyEnum_SortOrder_8iBc6wlNqBa9cju9cUAhUAxA) 1));

and hangs.

On Windows the Nim version failing this test is:

Nim Compiler Version 0.17.3 (2017-11-12) [Windows: amd64]
Copyright (c) 2006-2017 by Andreas Rumpf

git hash: 22ceab0
active boot switches: -d:release

(On Windows the compiler doesn't hang as on Linux, but simply crashes.)

The same test passed on 0.17.2 (and on earlier versions of 0.17.3)

discard """
  output: @[0, 4, 9, 1, 3, 2]
@[0, 1, 2, 3, 9]
"""

import algorithm

type
  Bar = object
    bar: ref seq[int]
  Foo = ref Bar

proc test(x: ref Foo) =
  x.bar[].del(1)
  x.bar[].sort(cmp)

proc main() =
  var foo: ref Foo
  new(foo)

  var s = @[0, 4, 9, 1, 3, 2]

  var sr: ref seq[int]
  new(sr)
  sr[] = s

  foo[] = Foo(bar: sr)
  echo($foo.bar[])

  test(foo)
  echo($foo.bar[])

main()
@skilchen skilchen changed the title sorting via reference hangs compiler Nim 0.17.3: sorting via reference hangs compiler Nov 11, 2017
@skilchen skilchen changed the title Nim 0.17.3: sorting via reference hangs compiler Nim #head: sorting via reference hangs compiler Nov 12, 2017
@skilchen
Copy link
Contributor Author

my first attempt at bisecting:

b407f083bafa227470caa077b2f70a6bc4da2dc3 is the first bad commit
commit b407f083bafa227470caa077b2f70a6bc4da2dc3
Author: Araq 
Date:   Tue Oct 24 09:40:28 2017 +0200

    destructors: work in progress

:040000 040000 0253fb2bb0d67a39d47a29ac41d4dc42fedb4f73 046678f702bca94d05ffe09e6028ffb569913bc2 M	compiler
:040000 040000 15808b10bdf8fb1c1d26f8a338bc1e56e022700f cbc8964b93ceb94f8d87243f639b7fcbdb712df0 M	lib
:040000 040000 f87f1a5fc1f5094352f01d8bd9a60428cd5fa3ef aefac571ad71cdd5a5e8c416d6e8802af01b7749 M	tests

The first bad commit translates my test to:

N_NIMCALL(void, test_BN7jJb30AIoqmGLz9c6zhkw)(tyObject_Bar_jvMTkVWUjBFb12b6SKU1qg** x) {
	tyProc_fDD7zVPPl59bNBu4ChTEQeQ T1_;
	nimfr_("test", "t1.nim");
	nimln_(14, "t1.nim");
	del_piMKKyQMYfDFMeykSxoPAg((*(*x)).bar, ((NI) 1));
	nimln_(15, "t1.nim");
	memset((void*)(&T1_), 0, sizeof(T1_));
	T1_.ClP_0 = ((TM_T8UX4uCLBe2k9c29b5ubzYSA_2) (cmp_8Eruo47qvrfENwO9aWPZfBQ_3)); T1_.ClE_0 = NIM_NIL;
	sort_84EnBzTXl9c1maQcyvYsKBQ((*(*x)).bar, (*(*x)).barLen_0, T1_, ((tyEnum_SortOrder_8iBc6wlNqBa9cju9cUAhUAxA) 1));
	popFrame();
}

and the last good commit to:

N_NIMCALL(void, test_BN7jJb30AIoqmGLz9c6zhkw)(tyObject_Bar_jvMTkVWUjBFb12b6SKU1qg** x) {
	tyProc_fDD7zVPPl59bNBu4ChTEQeQ T1_;
	nimfr_("test", "t1.nim");
	nimln_(14, "t1.nim");
	del_piMKKyQMYfDFMeykSxoPAg((*(*x)).bar, ((NI) 1));
	nimln_(15, "t1.nim");
	memset((void*)(&T1_), 0, sizeof(T1_));
	T1_.ClP_0 = ((TM_T8UX4uCLBe2k9c29b5ubzYSA_2) (cmp_8Eruo47qvrfENwO9aWPZfBQ_3)); T1_.ClE_0 = NIM_NIL;
	sort_84EnBzTXl9c1maQcyvYsKBQ((*(*(*x)).bar)->data, (*(*(*x)).bar)->Sup.len, T1_, ((tyEnum_SortOrder_8iBc6wlNqBa9cju9cUAhUAxA) 1));
	popFrame();
}

@Araq Araq closed this as completed in d072229 Nov 18, 2017
@skilchen
Copy link
Contributor Author

thanks for the fix!

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