When attempting to modify a field in a struct variable that is captured from the enclosing scope MiniFB crashes. If the struct variable is global then MiniFB doesn't segfault.
See the function onkeypress below for the assignment that causes the segfault.
version info:
Julia Version 1.5.2
Commit 539f3ce943 (2020-09-23 23:17 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: AMD EPYC 7702P 64-Core Processor
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-9.0.1 (ORCJIT, znver2)
Environment:
JULIA_NUM_THREADS = 64
JULIA_EDITOR = "/usr/share/code/code"julia> using MiniFB
minimum working example:
julia> mutable struct Simple
a::Float64
end
julia> function mwe()
width = 600
height = 600
window = mfb_open_ex("Luxor -> MiniFB", width, height, MiniFB.WF_RESIZABLE)
t = Simple(1.0)
function onkeypress(window::Ptr{Cvoid}, key::mfb_key, mod::mfb_key_mod, ispressed::Bool)
t.a += 1 #this causes the segfault. If t is a global variable no segfault
return nothing
end
mfb_set_target_fps(60)
mfb_set_keyboard_callback(window, onkeypress)
while mfb_wait_sync(window) # The Luxor `@imagematrix` macro creates a 2D matrix of Color objects in ARGB32 format, which is exactly what MiniFB requires
buffer = Luxor.@imagematrix begin
Luxor.background("grey40")
end 600 600
# The image matrix created by Luxor is, in standard Julia convention, column first. The buffer
# expected by MiniFB is row first. The call to `permutedims` makes that change.
state = mfb_update(window, permutedims(buffer, (2, 1)))
# Exit when the user closes the window.
if state != MiniFB.STATE_OK
break
end
end
mfb_close(window)
end
mwe (generic function with 1 method)
julia> mwe()
Window created using X11 API
signal (11): Segmentation fault
in expression starting at REPL[5]:1
unknown function (ip: 0x7f7e8800cfc3)
Allocations: 11027408 (Pool: 11024513; Big: 2895); GC: 24
Segmentation fault (core dumped)
When attempting to modify a field in a struct variable that is captured from the enclosing scope MiniFB crashes. If the struct variable is global then MiniFB doesn't segfault.
See the function onkeypress below for the assignment that causes the segfault.
version info:
Julia Version 1.5.2
Commit 539f3ce943 (2020-09-23 23:17 UTC)
Platform Info:
OS: Linux (x86_64-pc-linux-gnu)
CPU: AMD EPYC 7702P 64-Core Processor
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-9.0.1 (ORCJIT, znver2)
Environment:
JULIA_NUM_THREADS = 64
JULIA_EDITOR = "/usr/share/code/code"julia> using MiniFB
minimum working example: