JuliaGraphics / Gtk.jl

Julia interface to Gtk windowing toolkit.
Other
287 stars 80 forks source link

Segfault in g_sigatom #336

Open SimonDanisch opened 6 years ago

SimonDanisch commented 6 years ago

https://github.com/JuliaGraphics/Gtk.jl/blob/master/src/GLib/signals.jl#L167 Julia 0.6.1, linux, gdb stack trace:

julia> 
Thread 1 "julia" received signal SIGSEGV, Segmentation fault.
__GI___pthread_mutex_lock (mutex=0x0) at ../nptl/pthread_mutex_lock.c:67
67  ../nptl/pthread_mutex_lock.c: No such file or directory.
(gdb) backtrace
#0  __GI___pthread_mutex_lock (mutex=0x0) at ../nptl/pthread_mutex_lock.c:67
#1  0x00007fffc237fbfa in XrmQGetResource ()
   from /usr/lib/x86_64-linux-gnu/libX11.so.6
#2  0x00007fffc235bf86 in XGetDefault ()
   from /usr/lib/x86_64-linux-gnu/libX11.so.6
#3  0x00007fffaabac93f in ?? () from /usr/lib/x86_64-linux-gnu/libcairo.so.2
#4  0x00007fffaabaee60 in ?? () from /usr/lib/x86_64-linux-gnu/libcairo.so.2
#5  0x00007fffaab80627 in cairo_surface_get_font_options ()
   from /usr/lib/x86_64-linux-gnu/libcairo.so.2
#6  0x00007fffaab3ecff in ?? () from /usr/lib/x86_64-linux-gnu/libcairo.so.2
#7  0x00007fffaab41e13 in ?? () from /usr/lib/x86_64-linux-gnu/libcairo.so.2
#8  0x00007fffaab33a44 in cairo_show_glyphs ()
   from /usr/lib/x86_64-linux-gnu/libcairo.so.2
#9  0x00007fffc267c22b in ?? ()
   from /usr/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0
#10 0x00007fffc267c5bf in ?? ()
   from /usr/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0
#11 0x00007fffa9d6dc79 in pango_renderer_draw_glyphs ()
   from /usr/lib/x86_64-linux-gnu/libpango-1.0.so.0
#12 0x00007fffa9d6e930 in pango_renderer_draw_layout_line ()
   from /usr/lib/x86_64-linux-gnu/libpango-1.0.so.0
#13 0x00007fffa9d6eb45 in pango_renderer_draw_layout ()
   from /usr/lib/x86_64-linux-gnu/libpango-1.0.so.0
---Type <return> to continue, or q <return> to quit---
#14 0x00007fffc267c76a in ?? () from /usr/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0
#15 0x00007fffc51db75e in gtk_render_layout () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#16 0x00007fffc51e593e in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#17 0x00007fffc52b1917 in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#18 0x00007fffc52b1f23 in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#19 0x00007fffc50a925b in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#20 0x00007fffc50ad962 in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#21 0x00007fffc5069492 in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#22 0x00007fffc52b1917 in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#23 0x00007fffc52b1f23 in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#24 0x00007fffc50a925b in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#25 0x00007fffc50ad962 in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#26 0x00007fffc5069492 in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#27 0x00007fffc52b1917 in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#28 0x00007fffc52b1f23 in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#29 0x00007fffc50a925b in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#30 0x00007fffc50ad962 in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#31 0x00007fffc52bc839 in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#32 0x00007fffc52b1917 in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#33 0x00007fffc52b1d17 in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#34 0x00007fffc52b1f02 in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#35 0x00007fffc52b214b in gtk_widget_send_expose () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#36 0x00007fffc5166052 in gtk_main_do_event () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#37 0x00007fffc4cb6d08 in ?? () from /usr/lib/x86_64-linux-gnu/libgdk-3.so.0
#38 0x00007fffc4cb7e2c in ?? () from /usr/lib/x86_64-linux-gnu/libgdk-3.so.0
#39 0x00007fffc4cb7fe3 in ?? () from /usr/lib/x86_64-linux-gnu/libgdk-3.so.0
#40 0x00007fffabacf1d4 in ?? () from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so
#41 0x00007fffabae99a6 in g_signal_emit_valist () from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so
#42 0x00007fffabaea555 in g_signal_emit_by_name () from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so
#43 0x00007fffc4cb0fc7 in ?? () from /usr/lib/x86_64-linux-gnu/libgdk-3.so.0
#44 0x00007fffc4ca03c8 in ?? () from /usr/lib/x86_64-linux-gnu/libgdk-3.so.0
#45 0x00007fffab7f8ab3 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#46 0x00007fffab7f804a in g_main_context_dispatch () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#47 0x00007fffab7f83f0 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#48 0x00007fffab7f8712 in g_main_loop_run () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#49 0x00007fffc5165395 in gtk_main () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#50 0x00007fffb0235200 in julia_#229_62878 () at /home/s/.julia/v0.6/Gtk/src/events.jl:2
#51 0x00007fffb0235220 in jlcall_#229_62877 ()
#52 0x00007ffff7708b67 in jl_call_fptr_internal (fptr=<synthetic pointer>, fptr=<synthetic pointer>, nargs=1, args=0x7fffffffce50, meth=<optimized out>) at /home/s/juliastuff/julia06dev/src/julia_internal.h:339
#53 jl_call_method_internal (nargs=1, args=0x7fffffffce50, meth=<optimized out>) at /home/s/juliastuff/julia06dev/src/julia_internal.h:358
#54 jl_apply_generic (args=0x7fffffffce50, nargs=<optimized out>) at /home/s/juliastuff/julia06dev/src/gf.c:1926
#55 0x00007fffb0234bd1 in julia_g_sigatom_62877 () at /home/s/.julia/v0.6/Gtk/src/GLib/signals.jl:167
#56 0x00007fffb02351e3 in jlcall_g_sigatom_62876 ()
#57 0x00007ffff7708b67 in jl_call_fptr_internal (fptr=<synthetic pointer>, fptr=<synthetic pointer>, nargs=2, args=0x7fffffffcfe8, meth=<optimized out>) at /home/s/juliastuff/julia06dev/src/julia_internal.h:339
#58 jl_call_method_internal (nargs=2, args=0x7fffffffcfe8, meth=<optimized out>) at /home/s/juliastuff/julia06dev/src/julia_internal.h:358
#59 jl_apply_generic (args=args@entry=0x7fffffffcfe8, nargs=nargs@entry=2) at /home/s/juliastuff/julia06dev/src/gf.c:1926
#60 0x00007ffff7708d26 in jl_apply (nargs=2, args=0x7fffffffcfe8) at /home/s/juliastuff/julia06dev/src/julia.h:1424
#61 jl_invoke (meth=<optimized out>, args=0x7fffffffcfe8, nargs=2) at /home/s/juliastuff/julia06dev/src/gf.c:51
#62 0x00007fffb02349ed in julia_gtk_main_62876 () at /home/s/.julia/v0.6/Gtk/src/events.jl:1
#63 0x00007fffb0234a10 in jlcall_gtk_main_62875 ()
#64 0x00007ffff7708b67 in jl_call_fptr_internal (fptr=<synthetic pointer>, fptr=<synthetic pointer>, nargs=1, args=0x7fffacffd7f0, meth=<optimized out>) at /home/s/juliastuff/julia06dev/src/julia_internal.h:339
#65 jl_call_method_internal (nargs=1, args=0x7fffacffd7f0, meth=<optimized out>) at /home/s/juliastuff/julia06dev/src/julia_internal.h:358
#66 jl_apply_generic (args=args@entry=0x7fffacffd7f0, nargs=nargs@entry=1) at /home/s/juliastuff/julia06dev/src/gf.c:1926
#67 0x00007ffff7722a30 in jl_apply (nargs=1, args=0x7fffacffd7f0) at /home/s/juliastuff/julia06dev/src/julia.h:1424
#68 start_task () at /home/s/juliastuff/julia06dev/src/task.c:267
#69 0x0000000000000000 in ?? ()
(gdb) 

I played around a bit with g_sigatom, which the stack trace points to, but didn't really figure out how it's supposed to work. What I did figure out was, that ret = f() doesn't actually return, so I was thinking there might be a yield in there, but seems like the f that got called is just a plain ccall (ccall((:gtk_widget_show_all, libgtk), Void, (Ptr{GObject},), w), I think)... So I'm not really sure what's going on here...

Full code (will try to make an mwe if I have time):

# module gtk_glviz
  # export openmainwind
  using Gtk, GLWindow, GLAbstraction, Reactive, GeometryTypes, Colors, GLVisualize
  using GtkReactive
  using Gtk.GConstants, ModernGL

  """
  A basic GTK gui for testing purpose -- some of the setup hacked from Simon's
      prototype
  """
  function openmainwind()

    resolution = (1920, 1080)
    name = "Test"
    mainwin = Gtk.Window(name, resolution..., true, true)
    Gtk.visible(mainwin, true)
    Gtk.setproperty!(mainwin, Symbol("is-focus"), false)

    glvizbox = Gtk.Box(:h)
    guibox= Gtk.Box(:v)
    a = GtkScale(false, 0:255)
    b = GtkScale(false, 0:255)
    c = GtkScale(false, 0:255)
    vizbut = Gtk.Button("Visualize!")
    # --- Signal to add another cat on second screen: fails!
    vis_s = Gtk.signal_connect(vizbut,"clicked") do widget
        r = getproperty(GtkAdjustment(a),:value,Int64)
        g = getproperty(GtkAdjustment(b),:value,Int64)
        b = getproperty(GtkAdjustment(c),:value,Int64)
        mesh_color = RGBA{Float32}(r,g,b,1)
        viz_test(mesh_color, sc2)
    end
    push!(guibox,a,b,c,vizbut)
    push!(glvizbox, guibox) # not legenat but I am having trouble making it work wiht a grid
    push!(mainwin,glvizbox)
    viz = setup_screen()
    push!(glvizbox, viz)
    Gtk.setproperty!(glvizbox, :expand, viz, true)

    return mainwin
    # Gtk.showall(mainwin)

  end

  """
  Other misc. functions to make this work for multiple screens
  """
  function y_part(area, percent)
      amount = percent / 100.0
      p = const_lift(area) do r
          (
              SimpleRectangle{Int}(r.x, r.y, r.w, round(Int, r.h*amount)),
              SimpleRectangle{Int}(r.x, r.y+round(Int, r.h*amount), r.w, round(Int, r.h*(1-amount)))
          )
      end
      return map(first, p), map(last, p)
  end
  function x_part(area, percent)
      amount = percent / 100.0
      p = const_lift(area) do r
          (
              SimpleRectangle{Int}(r.x, r.y, round(Int, r.w*amount), r.h ),
              SimpleRectangle{Int}(r.x+round(Int, r.w*amount), r.y, round(Int, r.w*(1-amount)), r.h)
          )
      end
      return map(first, p), map(last, p)
  end

  """
  Mouse events adapted from Simon's Visualize mod by Loic -- probably all wrong ...
  """
  function addScrollEvt!(window::GLWindow.Screen)
      function callback_w(widget::Gtk.GtkGLArea, width::Int32, height::Int32)
          rect_signal = window.inputs[:window_area]
          push!(rect_signal,  IRect(minimum(value(rect_signal)), width, height) )
          return true
      end
      gl_area = window.glcontext.window # the Gtk.gl_area
      signal_connect(callback_w, gl_area, "scroll-event")
      add_events(gl_area, GConstants.GdkEventMask.SCROLL) # same
      return
  end

  function addScroll!(window::GLWindow.Screen)
      function callback(widget::Gtk.GtkGLArea, s::Gtk.GdkEventScroll)
          scro = window.inputs[:scroll]
          push!(scro, (s.x, s.y))
          return true
      end
      gl_area = window.glcontext.window # the Gtk.gl_area
      signal_connect(callback, gl_area, "scroll-event")
      add_events(gl_area, GConstants.GdkEventMask.SCROLL) # same
      return
  end
  function addMouse!(window::GLWindow.Screen)
        function callback(widget::Gtk.GtkGLArea, s::Gtk.GdkEventMotion)
            pos = window.inputs[:mouseposition]
            push!(pos,(s.x, s.y))
            return true
        end
        gl_area = window.glcontext.window # the Gtk.gl_area
        add_events(gl_area, GConstants.GdkEventMask.POINTER_MOTION)
        signal_connect(callback, gl_area, "motion-notify-event")
        return true
    end

    # function to_mouse_button(x)
    #     if x == 1
    #         Mouse.left
    #     elseif x == 2
    #         Mouse.middle
    #     elseif x == 3
    #         Mouse.right
    #     else
    #         # TODO turn into error
    #         warn("Button is $x, while $(Gtk.GdkModifierType.BUTTON1)")
    #         Mouse.left
    #     end
    # end
    # function addMouseBut!(window::GLWindow.Screen)
    #     function callback(widget::Gtk.GtkGLArea, event::Gtk.GdkEventButton)
    #         button = to_mouse_button(event.button)
    #         action = event.event_type
    #         set = window.inputs[:mouse_buttons]
    #         if action in (GdkEventType.BUTTON_PRESS:GdkEventType.TRIPLE_BUTTON_PRESS)
    #             push!(set, button)
    #         elseif action == GdkEventType.BUTTON_RELEASE
    #             delete!(set, button)
    #         else
    #             warn("unknown action: $(action)")
    #         end
    #         push!(window.inputs[:mouse_buttons],set) # trigger setfield event!
    #         return true
    #     end
    #     gl_area = window.glcontext.window # the Gtk.gl_area
    #     add_events(gl_area,
    #         GConstants.GdkEventMask.GDK_BUTTON_PRESS_MASK |
    #         GConstants.GdkEventMask.GDK_BUTTON_RELEASE_MASK
    #     )
    #     signal_connect(callback, gl_area, "button_press_event")
    #     signal_connect(callback, gl_area, "button_release_event")
    #     return
    # end

  """
  Simon's GTK + GLVISUALIZE prototype, modified by Loic for experimental purposes...
  """
  mutable struct GtkContext <: GLWindow.AbstractContext
      window::Gtk.GLArea
      framebuffer::GLWindow.GLFramebuffer
  end
  function make_context_current(screen::Screen)
      gl_area = screen.glcontext.window
      Gtk.make_current(gl_area)
  end
  GLWindow.isopen(x::Gtk.GLArea) = true

  global screen = Ref{Screen}()
  function init_screen(gl_area, resolution, mesh_color)
      Gtk.make_current(gl_area)
      gtk_context = GtkContext(gl_area, GLWindow.GLFramebuffer(Signal(resolution)))
      window_area = Signal(SimpleRectangle(0, 0, resolution...))
      signals = Dict(
          :mouse_button_released => Reactive.Signal(0),
          :mouse_buttons_pressed => Reactive.Signal(Set(Int[])),
          :scroll => Reactive.Signal(Vec(0.0, 0.0)),
          :buttons_pressed => Reactive.Signal(Set(Int[])),
          :window_size => Reactive.Signal(Vec(resolution...)),
          :window_area => window_area,
          :cursor_position => Reactive.Signal(Vec(0.0,0.0)),
          :mouseinside => Reactive.Signal(true),
          :mouse_button_down => Reactive.Signal(0),
          :mouseposition => Reactive.Signal(Vec(0.0, 0.0)),
          :framebuffer_size => Reactive.Signal(Vec(resolution...)),
          :button_down => Reactive.Signal(0),
          :button_released => Reactive.Signal(0),
          :window_open => Reactive.Signal(true),
          :keyboard_buttons => Reactive.Signal((0,0,0,0)),
          :mouse2id => Signal(GLWindow.SelectionID{Int}(-1, -1))
      )
      screen[] = Screen(
          Symbol("GLVisualize"), window_area, nothing,
          Screen[], signals,
          (), false, true, RGBA(1f0,1f0,1f0,1f0), (0f0, RGBA(0f0,0f0,0f0,0f0)),
          Dict{Symbol, Any}(),
          gtk_context
      )
      addScroll!(screen[])
      addScrollEvt!(screen[])
      GLVisualize.add_screen(screen[])

      a1, a2 =  y_part(screen[].area, 50)
      global sc1
      global sc2 # (failed) attempt to return "screens" from signal and plot more later
      sc1 = Screen(screen[], area=a1)
      sc2 = Screen(screen[], area=a2)

      timesignal = viz_test(mesh_color, sc1)
      foreach(timesignal) do x
          # render a frame each time rotation updates
          Gtk.queue_render(gl_area)
          return
      end

  end

  function render_gtk(window, gtk_area)
      !isopen(window) && return
      fb = GLWindow.framebuffer(window)
      wh = GeometryTypes.widths(window)
      resize!(fb, wh)
      w, h = wh
      #prepare for geometry in need of anti aliasing
      glBindFramebuffer(GL_FRAMEBUFFER, fb.id[1]) # color framebuffer
      glDrawBuffers(2, [GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1])
      # setup stencil and backgrounds
      glEnable(GL_STENCIL_TEST)
      glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE)
      glStencilMask(0xff)
      glClearStencil(0)
      glClearColor(0,0,0,0)
      glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_COLOR_BUFFER_BIT)
      glEnable(GL_SCISSOR_TEST)
      GLWindow.setup_window(window, false)
      glDisable(GL_SCISSOR_TEST)
      glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE)
      # deactivate stencil write
      glEnable(GL_STENCIL_TEST)
      glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE)
      glStencilMask(0x00)
      GLAbstraction.render(window, true)
      glDisable(GL_STENCIL_TEST)

      # transfer color to luma buffer and apply fxaa
      glBindFramebuffer(GL_FRAMEBUFFER, fb.id[2]) # luma framebuffer
      glDrawBuffer(GL_COLOR_ATTACHMENT0)
      glClearColor(0,0,0,0)
      glClear(GL_COLOR_BUFFER_BIT)
      glViewport(0, 0, w, h)
      GLAbstraction.render(fb.postprocess[1]) # add luma and preprocess

      glBindFramebuffer(GL_FRAMEBUFFER, fb.id[1]) # transfer to non fxaa framebuffer
      glDrawBuffer(GL_COLOR_ATTACHMENT0)
      GLAbstraction.render(fb.postprocess[2]) # copy with fxaa postprocess

      #prepare for non anti aliased pass
      glDrawBuffers(2, [GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1])

      glEnable(GL_STENCIL_TEST)
      glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE)
      glStencilMask(0x00)
      GLAbstraction.render(window, false)
      glDisable(GL_STENCIL_TEST)
      # draw strokes
      glEnable(GL_SCISSOR_TEST)
      GLWindow.setup_window(window, true)
      glDisable(GL_SCISSOR_TEST)
      glViewport(0,0, wh...)
      #Read all the selection queries
      GLWindow.push_selectionqueries!(window)
      Gtk.attach_buffers(gtk_area) # transfer back to window
      glClearColor(0,0,0,0)
      glClear(GL_COLOR_BUFFER_BIT)
      GLAbstraction.render(fb.postprocess[3]) # copy postprocess
      return
  end
  function connect_renderloop(gl_area, resolution, mesh_color)

  end

  function viz_test(mesh_color, win)
      timesignal = loop(linspace(0f0,1f0,360))
        rotation_angle  = const_lift(*, timesignal, 2f0*pi)
        start_rotation  = Signal(rotationmatrix_x(deg2rad(90f0)))
        rotation        = map(rotationmatrix_y, rotation_angle)
        final_rotation  = map(*, start_rotation, rotation)
      _view(visualize(loadasset("cat.obj"), color = mesh_color, model = final_rotation), win)
      return timesignal
  end

  function setup_screen()
      resolution = (1920, 1080)
      mesh_color = Signal(RGBA{Float32}(1,0,0,1))
      gl_area = Gtk.GLArea()
      Gtk.gl_area_set_required_version(gl_area, 3, 3)
      GLAbstraction.new_context()
      Gtk.signal_connect(gl_area, "render") do gl_area, gdk_context
          if !isassigned(screen)
              init_screen(gl_area, resolution, mesh_color)
          end
          render_gtk(screen[], gl_area)
          glFlush()
          return false
      end
      return gl_area
  end

# end

# using Gtk
# using gtk_glviz

"""
Test run
"""

win = openmainwind()
Gtk.showall(win)
tknopp commented 6 years ago

In your callback you need to put @Gtk.sigatom in front of any expression that changes something in Gtk.

SimonDanisch commented 6 years ago

Oh duh!

Warning: it is essential to avoid task switching inside Gtk callbacks, as this corrupts the Gtk C-stack. For example, use @async print or queue a message for yourself. You can also call GLib.g_yield() if you need to block. However, if you are still seeing segfaults in some random method due to there existing a callback that recursively calls the glib main loop (such as making a dialog box) or otherwise causes g_yield to be called, wrap the faulting code in GLib.@sigatom. This will postpone execution of that code block until it can be run on the proper stack (but will otherwise acts like normal control flow).

Could we fail more gracefully? Although I guess we can't, if that warning is already in the README

tknopp commented 6 years ago

The situation is absolutely bad. I would love if someone could fix all this stuff.

tknopp commented 6 years ago

(I am unfortunately not capable of fixing these things)

SimonDanisch commented 6 years ago

But the @sigatom doesn't fix it, I think :( I'll try minimize the example, because right now, it's a bit too messy to really figure out what's going on! Well, at least I found out, that every ~3rd time the example code just works without a problem :D

tknopp commented 6 years ago

Where did you put it? at least in front of the the push! calls in the callbacks

SimonDanisch commented 6 years ago

Okay I reduced it to:

using Gtk, GLFW
using Gtk.GConstants

function setup_screen()
    resolution = (600, 500)
    name = "GTK + GLVisualize"
    parent = Gtk.Window(name, resolution..., true, true)
    Gtk.visible(parent, true)
    Gtk.setproperty!(parent, Symbol("is-focus"), false)
    box = Gtk.Box(:v)
    push!(parent, box)
    sl = Gtk.Scale(false, 0:10)
    push!(box, sl)
    gl_area = Gtk.GLArea()
    Gtk.gl_area_set_required_version(gl_area, 3, 3)
    push!(box, gl_area)
    Gtk.setproperty!(box, :expand, gl_area, true)
    Gtk.showall(parent)
    return parent
end
initialized = GLFW.Init()
parent = setup_screen();
Gtk.showall(parent)

the GLFW.Init() actually usually happens in GLFW.jl in __init__, but I commented that out to reduce the issue... This segfaults reliably on my system - not on my windows machine though :D

SimonDanisch commented 6 years ago

Newest gdb stack trace:

   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?help" for help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.6.1 (2017-10-24 22:15 UTC)
 _/ |\__'_|_|_|\__'_|  |  
|__/                   |  x86_64-linux-gnu

julia> using Gtk, GLFW
[Thread 0x7fffb5ffb700 (LWP 18585) exited]
[Thread 0x7fffb87fc700 (LWP 18584) exited]
[Thread 0x7fffbaffd700 (LWP 18583) exited]
[Thread 0x7fffbd7fe700 (LWP 18582) exited]
[Thread 0x7fffbffff700 (LWP 18581) exited]
[Thread 0x7fffc8d50700 (LWP 18580) exited]
[Thread 0x7fffc9551700 (LWP 18579) exited]
[New Thread 0x7fffb5ffb700 (LWP 18588)]
[New Thread 0x7fffb87fc700 (LWP 18589)]
[New Thread 0x7fffbaffd700 (LWP 18590)]

julia> function setup_screen()
           parent = Gtk.Window("GTK + GLVisualize", 600, 500, true, true)
           Gtk.visible(parent, true)
           box = Gtk.Box(:v)
           push!(parent, box)
           sl = Gtk.Scale(false, 0:10)
           push!(box, sl)
           gl_area = Gtk.GLArea()
           Gtk.gl_area_set_required_version(gl_area, 3, 3)
           push!(box, gl_area)
           Gtk.showall(parent)
           return parent
       end
setup_screen (generic function with 1 method)

julia> initialized = GLFW.Init()
true

julia> parent = setup_screen();

julia> 
Thread 1 "julia" received signal SIGSEGV, Segmentation fault.
__GI___pthread_mutex_lock (mutex=0x415353454d5f434c)
    at ../nptl/pthread_mutex_lock.c:67
67  ../nptl/pthread_mutex_lock.c: No such file or directory.
(gdb) stacktrace
Undefined command: "stacktrace".  Try "help".
(gdb) backtrace
#0  __GI___pthread_mutex_lock (mutex=0x415353454d5f434c)
    at ../nptl/pthread_mutex_lock.c:67
#1  0x00007fffbfafebfa in XrmQGetResource ()
   from /usr/lib/x86_64-linux-gnu/libX11.so.6
#2  0x00007fffbfadaf86 in XGetDefault ()
   from /usr/lib/x86_64-linux-gnu/libX11.so.6
#3  0x00007fffaa86393f in ?? () from /usr/lib/x86_64-linux-gnu/libcairo.so.2
#4  0x00007fffaa865e60 in ?? () from /usr/lib/x86_64-linux-gnu/libcairo.so.2
#5  0x00007fffaa837627 in cairo_surface_get_font_options ()
   from /usr/lib/x86_64-linux-gnu/libcairo.so.2
#6  0x00007fffaa7f5cff in ?? () from /usr/lib/x86_64-linux-gnu/libcairo.so.2
#7  0x00007fffaa7f8e13 in ?? () from /usr/lib/x86_64-linux-gnu/libcairo.so.2
#8  0x00007fffaa7eaa44 in cairo_show_glyphs ()
   from /usr/lib/x86_64-linux-gnu/libcairo.so.2
#9  0x00007fffbfdfb22b in ?? ()
   from /usr/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0
#10 0x00007fffbfdfb5bf in ?? ()
   from /usr/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0
#11 0x00007fffa9a24c79 in pango_renderer_draw_glyphs ()
   from /usr/lib/x86_64-linux-gnu/libpango-1.0.so.0
#12 0x00007fffa9a25930 in pango_renderer_draw_layout_line ()
   from /usr/lib/x86_64-linux-gnu/libpango-1.0.so.0
#13 0x00007fffa9a25b45 in pango_renderer_draw_layout ()
---Type <return> to continue, or q <return> to quit---
   from /usr/lib/x86_64-linux-gnu/libpango-1.0.so.0
#14 0x00007fffbfdfb76a in ?? ()
   from /usr/lib/x86_64-linux-gnu/libpangocairo-1.0.so.0
#15 0x00007fffc8eaa75e in gtk_render_layout ()
   from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#16 0x00007fffc8eb493e in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#17 0x00007fffc8f80917 in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#18 0x00007fffc8f80f23 in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#19 0x00007fffc8d7825b in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#20 0x00007fffc8d7c962 in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#21 0x00007fffc8d38492 in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#22 0x00007fffc8f80917 in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#23 0x00007fffc8f80f23 in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#24 0x00007fffc8d7825b in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#25 0x00007fffc8d7c962 in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#26 0x00007fffc8f8b839 in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#27 0x00007fffc8f80917 in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#28 0x00007fffc8f80d17 in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#29 0x00007fffc8f80f02 in ?? () from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#30 0x00007fffc8f8114b in gtk_widget_send_expose ()
   from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#31 0x00007fffc8e35052 in gtk_main_do_event ()
   from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
---Type <return> to continue, or q <return> to quit---
#32 0x00007fffc8985d08 in ?? () from /usr/lib/x86_64-linux-gnu/libgdk-3.so.0
#33 0x00007fffc8986e2c in ?? () from /usr/lib/x86_64-linux-gnu/libgdk-3.so.0
#34 0x00007fffc8986fe3 in ?? () from /usr/lib/x86_64-linux-gnu/libgdk-3.so.0
#35 0x00007fffab7861d4 in ?? ()
   from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so
#36 0x00007fffab7a09a6 in g_signal_emit_valist ()
   from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so
#37 0x00007fffab7a1555 in g_signal_emit_by_name ()
   from /usr/lib/x86_64-linux-gnu/libgobject-2.0.so
#38 0x00007fffc897ffc7 in ?? () from /usr/lib/x86_64-linux-gnu/libgdk-3.so.0
#39 0x00007fffc896f3c8 in ?? () from /usr/lib/x86_64-linux-gnu/libgdk-3.so.0
#40 0x00007fffab4afab3 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#41 0x00007fffab4af04a in g_main_context_dispatch ()
   from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#42 0x00007fffab4af3f0 in ?? () from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#43 0x00007fffab4af712 in g_main_loop_run ()
   from /lib/x86_64-linux-gnu/libglib-2.0.so.0
#44 0x00007fffc8e34395 in gtk_main ()
   from /usr/lib/x86_64-linux-gnu/libgtk-3.so.0
#45 0x00007fffafee0b60 in julia_#229_68391 ()
    at /home/s/.julia/v0.6/Gtk/src/events.jl:2
#46 0x00007fffafee0b80 in jlcall_#229_68390 ()
#47 0x00007ffff75e1250 in jl_call_fptr_internal (fptr=0x7fffffffcb30, 
---Type <return> to continue, or q <return> to quit---
    meth=0x7fffac6ef710, args=0x7fffffffcc80, nargs=1)
    at /home/s/juliastuff/julia06dev/src/julia_internal.h:339
#48 0x00007ffff75e1361 in jl_call_method_internal (meth=0x7fffac6ef710, 
    args=0x7fffffffcc80, nargs=1)
    at /home/s/juliastuff/julia06dev/src/julia_internal.h:358
#49 0x00007ffff75e7a32 in jl_apply_generic (args=0x7fffffffcc80, nargs=1)
    at /home/s/juliastuff/julia06dev/src/gf.c:1926
#50 0x00007fffafee042f in julia_g_sigatom_68389 (f=0x7fffecd38408)
    at /home/s/.julia/v0.6/Gtk/src/GLib/signals.jl:167
#51 0x00007fffafee0b43 in jlcall_g_sigatom_68388 ()
#52 0x00007ffff75e1250 in jl_call_fptr_internal (fptr=0x7fffffffce80, 
    meth=0x7fffac701090, args=0x7fffffffcf80, nargs=2)
    at /home/s/juliastuff/julia06dev/src/julia_internal.h:339
#53 0x00007ffff75e1361 in jl_call_method_internal (meth=0x7fffac701090, 
    args=0x7fffffffcf80, nargs=2)
    at /home/s/juliastuff/julia06dev/src/julia_internal.h:358
#54 0x00007ffff75e7a32 in jl_apply_generic (args=0x7fffffffcf80, nargs=2)
    at /home/s/juliastuff/julia06dev/src/gf.c:1926
#55 0x00007ffff75e0c64 in jl_apply (args=0x7fffffffcf80, nargs=2)
    at /home/s/juliastuff/julia06dev/src/julia.h:1424
#56 0x00007ffff75e14ff in jl_invoke (meth=0x7fffac701090, args=0x7fffffffcf80, 
    nargs=2) at /home/s/juliastuff/julia06dev/src/gf.c:51
#57 0x00007fffafee01fa in julia_gtk_main_68386 ()
---Type <return> to continue, or q <return> to quit---
    at /home/s/.julia/v0.6/Gtk/src/events.jl:1
#58 0x00007fffafee0240 in jlcall_gtk_main_68385 ()
#59 0x00007ffff75e1250 in jl_call_fptr_internal (fptr=0x7fffffffd030, 
    meth=0x7fffac6eeb90, args=0x7fffacf16f90, nargs=1)
    at /home/s/juliastuff/julia06dev/src/julia_internal.h:339
#60 0x00007ffff75e1361 in jl_call_method_internal (meth=0x7fffac6eeb90, 
    args=0x7fffacf16f90, nargs=1)
    at /home/s/juliastuff/julia06dev/src/julia_internal.h:358
#61 0x00007ffff75e7a32 in jl_apply_generic (args=0x7fffacf16f90, nargs=1)
    at /home/s/juliastuff/julia06dev/src/gf.c:1926
#62 0x00007ffff7606d5b in jl_apply (args=0x7fffacf16f90, nargs=1)
    at /home/s/juliastuff/julia06dev/src/julia.h:1424
#63 0x00007ffff7607ade in start_task ()
    at /home/s/juliastuff/julia06dev/src/task.c:267
#64 0x0000000000000000 in ?? ()