First suggestion: make sure you have read through the ccall section of the
manual:

http://docs.julialang.org/en/release-0.4/manual/calling-c-and-fortran-code/

(this is probably not the cause of the crash, but you may want to use e.g.
`Ptr{Int32}` if you are returning a pointer)

Second suggestion: make sure to match the calling convention used in your
library:

http://docs.julialang.org/en/release-0.4/manual/calling-c-and-fortran-code/#calling-convention

Finally, these kind of bugs are difficult to diagnose without more context.
If you can share a minimal example (C code + Julia code) that reproduces
the crash, then someone might be able to provide more concrete suggestions.



On Tue, Jan 26, 2016 at 2:13 PM, Júlio Dias <[email protected]> wrote:

> I really can´t understand what is going wrong. I would appreciate some help
>
> At first, I defined a function which calls a simple C DLL function
>
> function Study_create(iprt)
>   ptr_pointer = ccall((:Study_create,
> "MyLibraryWin32"),Int32,(Int32,),iprt)
>   return ptr_pointer
> end
>
> I have no problem to call my function Study_create. I can call it a number
> of times:
>
>         imap2 = Study_create(0)
>         imap3 = Study_create(0)
>         imap4 = Study_create(0)
>
> And if a watch imap2, imap3, imap4, the return values are ok.
>
> But if I write a loop to run the same idea:
>
> for test = 1:3
>       imap = Study_create(0)
> end
>
> Julia crashes in the first iteration(test=1) with this output:
>
> Please submit a bug report with steps to reproduce this fault, and any
> error mes
> sages that follow (in their entirety). Thanks.
> Exception: EXCEPTION_ACCESS_VIOLATION at 0x654513ae -- jl_init_types at
>  (unknow
> n line)
> jl_init_types at D:\Julia-0.4.0_x86\bin\libjulia.dll (unknown line)
> jl_init_types at D:\Julia-0.4.0_x86\bin\libjulia.dll (unknown line)
> jl_apply_generic at D:\Julia-0.4.0_x86\bin\libjulia.dll (unknown line)
> anonymous at D:\Julia-0.4.0_x86\examples\testepsrclasses\example1.jl:
> 27
> jl_eval_with_compiler_p at D:\Julia-0.4.0_x86\bin\libjulia.dll (unknown
> line)
> jl_parse_eval_all at D:\Julia-0.4.0_x86\bin\libjulia.dll (unknown line)
> jl_load_ at D:\Julia-0.4.0_x86\bin\libjulia.dll (unknown line)
> include at boot.jl:261
> jl_apply_generic at D:\Julia-0.4.0_x86\bin\libjulia.dll (unknown line)
> include_from_node1 at loading.jl:304
> jl_apply_generic at D:\Julia-0.4.0_x86\bin\libjulia.dll (unknown line)
> process_options at client.jl:308
> _start at client.jl:410
> jl_apply_generic at D:\Julia-0.4.0_x86\bin\libjulia.dll (unknown line)
> jl_get_global at D:\Julia-0.4.0_x86\bin\libjulia.dll (unknown line)
> unknown function (ip: 0040185B)
> unknown function (ip: 004026B3)
> unknown function (ip: 004013F0)
> BaseThreadInitThunk at C:\Windows\SYSTEM32\KERNEL32.DLL (unknown line)
> RtlInitializeExceptionChain at C:\Windows\SYSTEM32\ntdll.dll (unknown line)
> RtlInitializeExceptionChain at C:\Windows\SYSTEM32\ntdll.dll (unknown line)
>
> Even if I call directly ccall((:Study_create,
> "MyLibraryWin32"),Int32,(Int32,),0)I have the same problem
> Any Idea?
> Thank you.
>
>
>
>

Reply via email to