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

Invalid syntax cause a crash in Julia 1.0 #29145

Closed
inkydragon opened this issue Sep 12, 2018 · 2 comments · Fixed by #29154
Closed

Invalid syntax cause a crash in Julia 1.0 #29145

inkydragon opened this issue Sep 12, 2018 · 2 comments · Fixed by #29154
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior error handling Handling of exceptions by Julia or the user

Comments

@inkydragon
Copy link
Member

background

Somebody in Chinese Julia community wants to implement a STMonad in Julia, and he found this bug.

And I found that this code in julia 0.6.4 only cause a error, Julia also suggest that this code use a deprecated syntax. But in Julia 1.0 this cause a crash.

Error info

v 1.0.0

minimal reproducible example

struct STMonad{A,B}
	function STMonad()
		new{S,Ref{S}}() where S
	end
end

STMonad()

Julia info

julia> versioninfo()
Julia Version 1.0.0
Commit 5d4eaca0c9 (2018-08-08 20:58 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-5600U CPU @ 2.60GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.0 (ORCJIT, broadwell)

output

PS C:\Users\woclass\Desktop\`del> C:\Users\woclass\AppData\Local\Julia-1.0.0\bin\julia.exe .\STMonad.jl

Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ACCESS_VIOLATION at 0x6b5cf117 -- jl_new_structv at /home/Administrator/buildbot/worker/package_win64/build/src\datatype.c:774
in expression starting at C:\Users\woclass\Desktop\`del\STMonad.jl:7
jl_set_nth_field at /home/Administrator/buildbot/worker/package_win64/build/src\datatype.c:889 [inlined]
jl_new_structv at /home/Administrator/buildbot/worker/package_win64/build/src\datatype.c:781
Type at C:\Users\woclass\Desktop\`del\STMonad.jl:3
jl_fptr_trampoline at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:1829
jl_apply_generic at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:2182
do_call at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:324
eval_value at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:428
eval_stmt_value at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:363 [inlined]
eval_body at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:682
jl_interpret_toplevel_thunk_callback at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:799
unknown function (ip: FFFFFFFFFFFFFFFE)
unknown function (ip: 000000000EB4522F)
unknown function (ip: FFFFFFFFFFFFFFFF)
jl_toplevel_eval_flex at /home/Administrator/buildbot/worker/package_win64/build/src\toplevel.c:787
jl_parse_eval_all at /home/Administrator/buildbot/worker/package_win64/build/src\ast.c:838
jl_load at /home/Administrator/buildbot/worker/package_win64/build/src\toplevel.c:821 [inlined]
jl_load_ at /home/Administrator/buildbot/worker/package_win64/build/src\toplevel.c:828
include at .\boot.jl:317 [inlined]
include_relative at .\loading.jl:1038
include at .\sysimg.jl:29
jl_apply_generic at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:2182
exec_options at .\client.jl:229
_start at .\client.jl:421
jl_apply_generic at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:2182
jl_apply at /home/Administrator/buildbot/worker/package_win64/build/src\julia.h:1536 [inlined]
true_main at /home/Administrator/buildbot/worker/package_win64/build/ui\repl.c:112
wmain at /home/Administrator/buildbot/worker/package_win64/build/ui\repl.c:233
__tmainCRTStartup at /usr/src/debug/mingw64-x86_64-runtime-5.0.3-1/crt\crtexe.c:329
mainCRTStartup at /usr/src/debug/mingw64-x86_64-runtime-5.0.3-1/crt\crtexe.c:212
BaseThreadInitThunk at C:\WINDOWS\System32\KERNEL32.DLL (unknown line)
RtlUserThreadStart at C:\WINDOWS\SYSTEM32\ntdll.dll (unknown line)
Allocations: 5974 (Pool: 5964; Big: 10); GC: 0

v 0.6.4

And in Juliua 0.6.4 this code just cause a MethodError, not a crash.

julia> struct STMonad{A, B}
           function STMonad()
               new{S, Ref{S}}() where S
           end
       end

WARNING: deprecated syntax "inner constructor STMonad(...) around REPL[1]:3".
Use "STMonad{A,B}(...) where {A,B}" instead.

julia> STMonad()
ERROR: MethodError: no method matching STMonad()
@JeffBezanson JeffBezanson self-assigned this Sep 12, 2018
@yuyichao yuyichao changed the title deprecated syntax cause a crash in Julia 1.0 Invalid syntax cause a crash in Julia 1.0 Sep 12, 2018
@yuyichao
Copy link
Contributor

The deprecated syntax isn't an issue (it got a new meaning on 1.0 and isn't deprecated anymore).

new{S, Ref{S}}() where S is invalid code and that's what's causing the crash.

@JeffBezanson
Copy link
Member

Correct; that new expression basically expands to _allocate(STMonad{S,Ref{S}}) where S which is invalid for two reasons:

  1. The type has free variables and so cannot be constructed (this should give an error).
  2. The body of where S needs to be a type, but instead would be this (invalid) instance of STMonad. If you fix the deprecation warning on 0.6 you get:
julia> struct STMonad{A,B}
           function (::Type{STMonad})()
               new{S, Ref{S}}() where S
           end
       end

julia> STMonad()
ERROR: TypeError: UnionAll: expected Type, got STMonad{S,Ref{S}}
Stacktrace:
 [1] UnionAll(::TypeVar, ::Any) at ./boot.jl:263
 [2] STMonad() at ./REPL[1]:3

@JeffBezanson JeffBezanson added bug Indicates an unexpected problem or unintended behavior error handling Handling of exceptions by Julia or the user labels Sep 12, 2018
KristofferC pushed a commit that referenced this issue Sep 17, 2018
KristofferC pushed a commit that referenced this issue Feb 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior error handling Handling of exceptions by Julia or the user
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants