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

Assertion failed: cont_scope.has_free_params() #160

Open
michael-kenzel opened this issue Jun 13, 2024 · 2 comments
Open

Assertion failed: cont_scope.has_free_params() #160

michael-kenzel opened this issue Jun 13, 2024 · 2 comments

Comments

@michael-kenzel
Copy link
Contributor

This bug seems to only trigger on Windows (possibly only when built with MSVC).

The following example will reproduce the bug (compile with --emit-llvm, removing pretty much anything makes the bug disappear):

#[import(cc = "thorin")] fn cuda(_dev: i32, _grid: (i32, i32, i32), _block: (i32, i32, i32), _body: fn() -> ()) -> ();

enum needs_to_be_here_to_trigger_the_bug {
	A, B, C, D  // any fewer members will not trigger the bug
}

fn @no_bug_without_me_either(need: needs_to_be_here_to_trigger_the_bug) -> u32 {
	match need {
		needs_to_be_here_to_trigger_the_bug::A => 1,
		needs_to_be_here_to_trigger_the_bug::B => 2,
		needs_to_be_here_to_trigger_the_bug::C => 3,
		needs_to_be_here_to_trigger_the_bug::D => 4,
	}
}

struct G {
	xxx: fn(fn(C) -> ()) -> fn() -> (),
}

struct C {
}

fn @invoke(body: fn(C) -> ()) -> () {
	@body(C {})
}

fn @launch(device: i32, body: fn(G) -> ()) -> () {
	cuda(device, (1, 1, 1), (1, 1, 1), @|| @body(G {
		xxx = @|body| @|| invoke(body),
	}))
}

struct Device {
	launch: fn(fn(G) -> ()) -> (),
}

fn @createDevice(device: i32) {
	Device {
		launch = @|body| launch(device, body)
	}
}

#[export]
fn benchmark_print_info(device: i32) {
	createDevice(device);
	0
}

#[export]
fn benchmark_run(device: i32, argc: i32, argv: &mut u8) {
	createDevice(device);
}

results in

Assertion failed: cont_scope.has_free_params(), file src\thorin\analyses\scope.cpp, line 93
@Hugobros3
Copy link
Contributor

Can you provide a commit hash?

@michael-kenzel
Copy link
Contributor Author

thorin: fb0f721
artic: 0f50091011f2bf82efd460264f2f40781a85f72b
runtime: 5c1a78c07cbeaea16fd61c73e92fd7112dd62ab7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants