<p dir="auto">A user first reported this in <a href="https://groups.google.com/forum/#!topic/julia-users/TgKKZuB891I" rel="nofollow">https://groups.google.com/forum/#!topic/julia-users/TgKKZuB891I</a>. The following simple embedding program:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="#include &lt;julia.h&gt;

int main(int argc, char *argv[])
{
   jl_init(&quot;C:/tw/Julia-0.4.0/bin&quot;);
   jl_eval_string(&quot;println(sqrt(2.0))&quot;);
   jl_atexit_hook(0);
   return 0;
}"><pre class="notranslate"><code class="notranslate">#include &lt;julia.h&gt;

int main(int argc, char *argv[])
{
   jl_init("C:/tw/Julia-0.4.0/bin");
   jl_eval_string("println(sqrt(2.0))");
   jl_atexit_hook(0);
   return 0;
}
</code></pre></div>
<p dir="auto">produces:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ ./embed_test.exe

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 0x0 -- unknown function (ip: 0000000000000000)
unknown function (ip: 0000000000000000)"><pre class="notranslate"><code class="notranslate">$ ./embed_test.exe

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 0x0 -- unknown function (ip: 0000000000000000)
unknown function (ip: 0000000000000000)
</code></pre></div>
<p dir="auto">I've done some debugging with gdb and have traced it to some failure in <code class="notranslate">jl_module_run_initializer</code> called from <code class="notranslate">jl_init_restored_modules</code>.</p>
<p dir="auto">This scenario grew out of my investigation of why <strong>Base.Dates.unix2datetime</strong> was crashing, turns out it's not that function but <strong>round</strong>, I know, weird, rite?  Better to simply show an example</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="#include &lt;julia.h&gt;

int main(int argc, char *argv[])
{

    jl_init(JULIA_INIT_DIR);

    jl_eval_string(&quot;println(sqrt(2.0))&quot;);
    jl_eval_string(&quot;println(round(1.0))&quot;);

    return 0;
}"><pre class="notranslate"><code class="notranslate">#include &lt;julia.h&gt;

int main(int argc, char *argv[])
{

    jl_init(JULIA_INIT_DIR);

    jl_eval_string("println(sqrt(2.0))");
    jl_eval_string("println(round(1.0))");

    return 0;
}
</code></pre></div>
<p dir="auto">and built using the following Makefile in an msys2 env</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="JL_SHARE = $(shell julia -e 'print(joinpath(JULIA_HOME,Base.DATAROOTDIR,&quot;julia&quot;))')
CFLAGS   += $(shell $(JL_SHARE)/julia-config.jl --cflags)
CXXFLAGS += $(shell $(JL_SHARE)/julia-config.jl --cflags)
LDFLAGS  += $(shell $(JL_SHARE)/julia-config.jl --ldflags)
LDLIBS   += $(shell $(JL_SHARE)/julia-config.jl --ldlibs)
CC = gcc

all: embed_example"><pre class="notranslate"><code class="notranslate">JL_SHARE = $(shell julia -e 'print(joinpath(JULIA_HOME,Base.DATAROOTDIR,"julia"))')
CFLAGS   += $(shell $(JL_SHARE)/julia-config.jl --cflags)
CXXFLAGS += $(shell $(JL_SHARE)/julia-config.jl --cflags)
LDFLAGS  += $(shell $(JL_SHARE)/julia-config.jl --ldflags)
LDLIBS   += $(shell $(JL_SHARE)/julia-config.jl --ldlibs)
CC = gcc

all: embed_example
</code></pre></div>
<p dir="auto">Results in the following</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ make
gcc -DJULIA_INIT_DIR=\&quot;C:\\\\Julia\\\\julia-04051e9699\\\\lib\&quot; -IC:\\Julia\\julia-04051e9699\\include\\julia  -LC:\\Julia\\julia-04051e9699\\bin  embed_example.c  -ljulia -o embed_example

jeffw@xun MINGW64 ~/src/julia-embed-test
$ ./embed_example
1.4142135623730951

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 0x0 -- unknown function (ip: 0)
unknown function (ip: 0)"><pre class="notranslate"><code class="notranslate">$ make
gcc -DJULIA_INIT_DIR=\"C:\\\\Julia\\\\julia-04051e9699\\\\lib\" -IC:\\Julia\\julia-04051e9699\\include\\julia  -LC:\\Julia\\julia-04051e9699\\bin  embed_example.c  -ljulia -o embed_example

jeffw@xun MINGW64 ~/src/julia-embed-test
$ ./embed_example
1.4142135623730951

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 0x0 -- unknown function (ip: 0)
unknown function (ip: 0)
</code></pre></div>
<p dir="auto">The call to <strong>sqrt</strong> is not necessary to cause the error, just to give some context that the Julia engine is functioning.  It's not just <strong>round</strong> either, it's at least <strong>trunc</strong> as well and I suspect all of the <em>llvm</em> macros.  I have not managed to debug this more fully because it's not easy to know where to begin.  This does not happen on OS/X or Linux nor in a non-embedding scenario as can be seen when using the REPL of the same Julia install.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="$ julia
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type &quot;help()&quot; for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.4.0-dev+9597 (2015-05-23 02:32 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit 04051e9* (0 days old master)
|__/                   |  x86_64-w64-mingw32

julia&gt; round(2.0)
2.0"><pre class="notranslate"><code class="notranslate">$ julia
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: http://docs.julialang.org
   _ _   _| |_  __ _   |  Type "help()" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.4.0-dev+9597 (2015-05-23 02:32 UTC)
 _/ |\__'_|_|_|\__'_|  |  Commit 04051e9* (0 days old master)
|__/                   |  x86_64-w64-mingw32

julia&gt; round(2.0)
2.0
</code></pre></div>