<p dir="auto">Hello everybody.</p>
<p dir="auto">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...</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="julia&gt; 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"><pre class="notranslate"><code class="notranslate">julia&gt; 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
</code></pre></div>
<p dir="auto">This is first error message:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="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."><pre class="notranslate"><code class="notranslate">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.
</code></pre></div>
<p dir="auto">Second error message looks like this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="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)"><pre class="notranslate"><code class="notranslate">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)
</code></pre></div>
<p dir="auto">Another one:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="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)"><pre class="notranslate"><code class="notranslate">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)
</code></pre></div>
<p dir="auto">The last one:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="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)"><pre class="notranslate"><code class="notranslate">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)
</code></pre></div>
<p dir="auto">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:</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="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"><pre class="notranslate"><span class="pl-k">module</span> Test
  type Organism
    code<span class="pl-k">::</span><span class="pl-c1">Expr</span>
    codeFn<span class="pl-k">::</span><span class="pl-c1">Function</span>
  <span class="pl-k">end</span>
  type OrganismTask
    task<span class="pl-k">::</span><span class="pl-c1">Task</span>
    organism<span class="pl-k">::</span><span class="pl-c1">Organism</span>
  <span class="pl-k">end</span>

  tasks <span class="pl-k">=</span> OrganismTask[]

  <span class="pl-k">function</span> <span class="pl-en">born</span>(o<span class="pl-k">::</span><span class="pl-c1">Organism</span>)
    <span class="pl-k">return</span> <span class="pl-k">function</span> ()
      <span class="pl-k">while</span> <span class="pl-c1">true</span>
        <span class="pl-c1">produce</span>()
        <span class="pl-k">try</span>
          o<span class="pl-k">.</span><span class="pl-c1">codeFn</span>(o)
        <span class="pl-k">end</span>
      <span class="pl-k">end</span>
    <span class="pl-k">end</span>
  <span class="pl-k">end</span>

  <span class="pl-k">function</span> <span class="pl-en">run</span>()
    <span class="pl-k">for</span> i<span class="pl-k">=</span><span class="pl-c1">1</span><span class="pl-k">:</span><span class="pl-c1">500</span>
      <span class="pl-c"><span class="pl-c">#</span> in real app organism's function is more complicated</span>
      org  <span class="pl-k">=</span> <span class="pl-c1">Organism</span>(:(<span class="pl-k">function</span> (o) <span class="pl-k">return</span> <span class="pl-c1">1</span> <span class="pl-k">end</span>), <span class="pl-k">function</span> (o) <span class="pl-k">return</span> <span class="pl-c1">1</span> <span class="pl-k">end</span>)
      task <span class="pl-k">=</span> <span class="pl-c1">Task</span>(<span class="pl-c1">born</span>(org))
      <span class="pl-c1">push!</span>(tasks, <span class="pl-c1">OrganismTask</span>(task, org))
    <span class="pl-k">end</span>

    <span class="pl-k">while</span> <span class="pl-c1">true</span>
      <span class="pl-k">for</span> i<span class="pl-k">=</span><span class="pl-c1">1</span><span class="pl-k">:</span><span class="pl-c1">500</span>
        <span class="pl-c1">consume</span>(tasks[i]<span class="pl-k">.</span>task)

        <span class="pl-c"><span class="pl-c">#</span> here is a code, which modify tasks[i].organism.code</span>
        tasks[i]<span class="pl-k">.</span>organism<span class="pl-k">.</span>codeFn <span class="pl-k">=</span> <span class="pl-c1">eval</span>(tasks[i]<span class="pl-k">.</span>organism<span class="pl-k">.</span>code)
      <span class="pl-k">end</span>

      <span class="pl-c"><span class="pl-c">#</span> here is a code, which remove and add tasks from/to tasks variable</span>
    <span class="pl-k">end</span>
  <span class="pl-k">end</span>
<span class="pl-k">end</span></pre></div>
<p dir="auto">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.</p>
<p dir="auto">Thanks a lot. Julia is a great language ;)</p>
<p dir="auto">Hello,<br>
I am seeing memory corruption when repeatedly using <code class="notranslate">@eval</code>.  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.<br>
Thanks!</p>
<div class="highlight highlight-source-julia notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="function to_function(code::Expr)
  @eval f() = $code
  return f
end

function get_code()
  r1 = rand()
  r2 = rand()
  Expr(:comparison, r1, :&lt;, r2)
end

using Debug
@debug function script1()
  srand(0)
  for i = 1:100000
    code = &quot;nothing&quot;
    try
      code = get_code()
      f = to_function(code)
      f()
    catch e
      println(e)
      @bp
    end
    println(&quot;$i: code=$(string(code))&quot;)
  end
end"><pre class="notranslate"><span class="pl-k">function</span> <span class="pl-en">to_function</span>(code<span class="pl-k">::</span><span class="pl-c1">Expr</span>)
  <span class="pl-c1">@eval</span> <span class="pl-en">f</span>() <span class="pl-k">=</span> <span class="pl-k">$</span>code
  <span class="pl-k">return</span> f
<span class="pl-k">end</span>

<span class="pl-k">function</span> <span class="pl-en">get_code</span>()
  r1 <span class="pl-k">=</span> <span class="pl-c1">rand</span>()
  r2 <span class="pl-k">=</span> <span class="pl-c1">rand</span>()
  <span class="pl-c1">Expr</span>(<span class="pl-c1">:comparison</span>, r1, :<span class="pl-k">&lt;</span>, r2)
<span class="pl-k">end</span>

<span class="pl-k">using</span> Debug
<span class="pl-c1">@debug</span> <span class="pl-k">function</span> <span class="pl-en">script1</span>()
  <span class="pl-c1">srand</span>(<span class="pl-c1">0</span>)
  <span class="pl-k">for</span> i <span class="pl-k">=</span> <span class="pl-c1">1</span><span class="pl-k">:</span><span class="pl-c1">100000</span>
    code <span class="pl-k">=</span> <span class="pl-s"><span class="pl-pds">"</span>nothing<span class="pl-pds">"</span></span>
    <span class="pl-k">try</span>
      code <span class="pl-k">=</span> <span class="pl-c1">get_code</span>()
      f <span class="pl-k">=</span> <span class="pl-c1">to_function</span>(code)
      <span class="pl-c1">f</span>()
    <span class="pl-k">catch</span> e
      <span class="pl-c1">println</span>(e)
      <span class="pl-c1">@bp</span>
    <span class="pl-k">end</span>
    <span class="pl-c1">println</span>(<span class="pl-s"><span class="pl-pds">"</span><span class="pl-v">$i</span>: code=<span class="pl-v">$(<span class="pl-c1">string</span>(code))</span><span class="pl-pds">"</span></span>)
  <span class="pl-k">end</span>
<span class="pl-k">end</span></pre></div>