Issue 1:
Hello everybody.

It looks like i found a bundle of bugs in last version of julia. I run an application which uses many Tasks in it. It also uses generated julia code, which is run inside these tasks all the time. I obtain these crashes after ~3-20 minutes of running in some random order. I used both debug and release julia versions for tests...

julia> versioninfo()
Julia Version 0.4.3
Commit a2f713d (2016-01-12 21:37 UTC)
Platform Info:
System: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i7-4700HQ CPU @ 2.40GHz
WORD_SIZE: 64
BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Haswell)
LAPACK: libopenblas64_
LIBM: libopenlibm
LLVM: libLLVM-3.3

This is first error message:

A s s e r t i o n f a i l e d !

P r o g r a m : c : \ U s e r s \ U s e r \ A p p D a t a \ L o c a l \ J u l i a - 0 . 4 . 3 \ b i n \ j u l i a - d e b u g . e x e
F i l e : t o p l e v e l . c , L i n e 8 3 9

E x p r e s s i o n : j l _ i s _ f u n c t i o n ( f )

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

Second error message looks like this:

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 0x70116290 -- utf8proc_NFKC at c:\Users\User\AppData\Local\Julia-0.4.3\bin\libjulia-debug.dll (unknown line)
utf8proc_NFKC at c:\Users\User\AppData\Local\Julia-0.4.3\bin\libjulia-debug.dll (unknown line)
jl_static_eval at c:\Users\User\AppData\Local\Julia-0.4.3\bin\libjulia-debug.dll (unknown line)
jl_static_eval at c:\Users\User\AppData\Local\Julia-0.4.3\bin\libjulia-debug.dll (unknown line)
jl_static_eval at c:\Users\User\AppData\Local\Julia-0.4.3\bin\libjulia-debug.dll (unknown line)
jl_static_eval at c:\Users\User\AppData\Local\Julia-0.4.3\bin\libjulia-debug.dll (unknown line)
julia_type_to_llvm at c:\Users\User\AppData\Local\Julia-0.4.3\bin\libjulia-debug.dll (unknown line)
jl_compile at c:\Users\User\AppData\Local\Julia-0.4.3\bin\libjulia-debug.dll (unknown line)
jl_trampoline_compile_function at c:\Users\User\AppData\Local\Julia-0.4.3\bin\libjulia-debug.dll (unknown line)
jl_trampoline at c:\Users\User\AppData\Local\Julia-0.4.3\bin\libjulia-debug.dll (unknown line)
anonymous at G:\my\projects\jevo\src\Creature.jl:247
jl_get_system_hooks at c:\Users\User\AppData\Local\Julia-0.4.3\bin\libjulia-debug.dll (unknown line)
jl_get_system_hooks at c:\Users\User\AppData\Local\Julia-0.4.3\bin\libjulia-debug.dll (unknown line)

Another one:

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 0x64f417e8 -- jl_write_malloc_log at c:\Users\User\AppData\Local\Julia-0.4.3\bin\libjulia.dll (unknown line)
jl_write_malloc_log at c:\Users\User\AppData\Local\Julia-0.4.3\bin\libjulia.dll (unknown line)
jl_extern_c at c:\Users\User\AppData\Local\Julia-0.4.3\bin\libjulia.dll (unknown line)
jl_extern_c at c:\Users\User\AppData\Local\Julia-0.4.3\bin\libjulia.dll (unknown line)
jl_load_and_lookup at c:\Users\User\AppData\Local\Julia-0.4.3\bin\libjulia.dll (unknown line)
jl_compile at c:\Users\User\AppData\Local\Julia-0.4.3\bin\libjulia.dll (unknown line)
jl_trampoline at c:\Users\User\AppData\Local\Julia-0.4.3\bin\libjulia.dll (unknown line)
anonymous at g:\my\projects\jevo\src\Creature.jl:247
jl_unprotect_stack at c:\Users\User\AppData\Local\Julia-0.4.3\bin\libjulia.dll (unknown line)

The last one:

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 0x64f1732d -- jl_add_method at c:\Users\User\AppData\Local\Julia-0.4.3\bin\libjulia.dll (unknown line)
jl_add_method at c:\Users\User\AppData\Local\Julia-0.4.3\bin\libjulia.dll (unknown line)
jl_method_def at c:\Users\User\AppData\Local\Julia-0.4.3\bin\libjulia.dll (unknown line)
anonymous at no file:0
anonymous at g:\my\projects\jevo\src\Creature.jl:247
jl_unprotect_stack at c:\Users\User\AppData\Local\Julia-0.4.3\bin\libjulia.dll (unknown line)

It's hard to provide buggy code sample, because application is big and so many processes are involved. But, i may provide a high level code:

module Test
type Organism
code::Expr
codeFn::Function
end
type OrganismTask
task::Task
organism::Organism
end

tasks = OrganismTask[]

function born(o::Organism)
return function ()
while true
produce()
try
o.codeFn(o)
end
end
end
end

function run()
for i=1:500
# in real app organism's function is more complicated
org = Organism(:(function (o) return 1 end), function (o) return 1 end)
task = Task(born(org))
push!(tasks, OrganismTask(task, org))
end

while true
for i=1:500
consume(tasks[i].task)

# here is a code, which modify tasks[i].organism.code
tasks[i].organism.codeFn = eval(tasks[i].organism.code)
end

# here is a code, which remove and add tasks from/to tasks variable
end
end
end

If it's hard to find these errors using my sample, you may run my project on your machine to obtain the same errors. It doesn't require some special environment fo run. I may provide you exact steps to reproduce it.

Thanks a lot. Julia is a great language ;)

Issue 2:
Hello,

I am seeing memory corruption when repeatedly using @eval. Here is some example code to reproduce it. I have it failing on both Julia 0.3 and 0.4 at around 33000 iterations, where the eval'ed function hits corruption.

Thanks!

function to_function(code::Expr)
@eval f() = $code
return f
end

function get_code()
r1 = rand()
r2 = rand()
Expr(:comparison, r1, :<, r2)
end

using Debug
@debug function script1()
srand(0)
for i = 1:100000
code = "nothing"
try
code = get_code()
f = to_function(code)
f()
catch e
println(e)
@bp
end
println("$i: code=$(string(code))")
end
end