Skip to content

Strange code hang in combination with @generated functions #24763

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

Closed
Jutho opened this issue Nov 24, 2017 · 4 comments
Closed

Strange code hang in combination with @generated functions #24763

Jutho opened this issue Nov 24, 2017 · 4 comments
Labels
regression Regression in behavior compared to a previous version

Comments

@Jutho
Copy link
Contributor

Jutho commented Nov 24, 2017

This is the weirdest problem I have ever encountered in several years of using Julia and has taken me several hours to track down to debug and distill a minimal working example:

This came up in the context of an unregistered package of mine for working with strided array views (WIP, https://github.com/Jutho/Strided.jl), and only started to be a problem when I pulled the latest master today (I guess before I was working on master from a few days ago, at most two weeks or so).

module Strided
	struct StridedView{T,N,A<:DenseArray{T}} <: DenseArray{T,N}
		parent::A
		size::NTuple{N,Int}
		strides::NTuple{N,Int}
	end

	function Base.convert(T::Type{<:DenseArray}, a::StridedView)
	end

	@generated function test1(dims::NTuple{N,Int}) where {N}
		loopvars = [gensym() for k = 1:N]
		return :()
	end

	function test2()
	end
end
dims=(1,)
Strided.test1(dims) #-> code hangs

The hanging will stop under any of the following modifications:

  • remove function test2() end such that the generated function is the last in the module.
  • add @show "hi $N" as first line of test1, however
    • the "hi" is important, @show "$N" is not sufficient
    • the display output is important, t=@elapsed "$N" is not sufficient but @time "hi $N" is, in fact with @time the hi is not necessary
    • the macro is important, println("hi $N") is not sufficient
  • remove the definition of Base.convert
  • simplify the type definition of StridedView
@Jutho Jutho added the regression Regression in behavior compared to a previous version label Nov 24, 2017
@maleadt
Copy link
Member

maleadt commented Nov 25, 2017

Bisected to 80d8719 (cc @JeffBezanson)

@Jutho
Copy link
Contributor Author

Jutho commented Nov 25, 2017

Thanks Tim.

@Jutho
Copy link
Contributor Author

Jutho commented Dec 3, 2017

If I want to prepare a PR to fix this, should I just revert the change (code addition) of 80d8719 in inference.jl? Or is there another fix in the making, @JeffBezanson ?

@Jutho
Copy link
Contributor Author

Jutho commented Dec 7, 2017

This seems fixed on latest master, probably due to recent changes in inference.jl originating from #24362. So thanks @vtjnash for implicitly solving this issue as well.

@Jutho Jutho closed this as completed Dec 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression Regression in behavior compared to a previous version
Projects
None yet
Development

No branches or pull requests

2 participants