lylejohnson / fxruby

FXRuby is an extension module for Ruby that provides an interface to the FOX GUI toolkit.
http://www.fxruby.org/
51 stars 5 forks source link

posibly [BUG] Segmentation fault when exit the main loop #6

Closed damian-m-g closed 12 years ago

damian-m-g commented 12 years ago

Hello, this happens when you exit the main loop(close application by the x button or by right click >> close in the toolbar of a Windows SP3 OS). This is the code who generate it, be aware that it happen only when I use FXSplashWindow:

Observe that this is optimized for show the logo as quickly is possible, anyway I've tried many ways of show the splash window(and what is next), and every time the BUG arise.

require 'fox16' include Fox

if FILE == $0 FXApp.new('X, 'X') do |app|

With and without disabling threads support fails

app.disableThreads
logo = Fox::FXSplashWindow.new(app, Fox::FXBMPIcon.new(app, File.open('./Recursos Fijos/CAPSI Evolution logo de carga.bmp', 'rb').read), SPLASH_SIMPLE|SPLASH_OWNS_ICON)
app.create
logo.show(PLACEMENT_SCREEN)
app.addTimeout(100) do
  require './Biblioteca/Mod General'
  require './Biblioteca/Mod Materiales'
  require './Biblioteca/Vis Materiales'
  require './Biblioteca/Vis Interfaz Principal.rb'
  #VenPrincipal is subclass of FXMainWindow
  v = VenPrincipal.new(app)
  v.create
  v.show(PLACEMENT_SCREEN)
  logo.destroy
end
app.run

end end

This work fine, until I close the application, then I got this in the shell:

C:\Archivos de programa\Aptana\Aptana Studio 3\WORKSPACE\CAPSI Evolution>ruby '. /Biblioteca/Iniciador.rb' ./Biblioteca/Iniciador.rb: [BUG] Segmentation fault ruby 1.9.3p194 (2012-04-20) [i386-mingw32]

-- Control frame information ----------------------------------------------- c:0001 p:0000 s:0002 b:0002 l:00056c d:00056c TOP

-- C level backtrace information ------------------------------------------- C:\WINDOWS\system32\ntdll.dll(KiFastSystemCallRet+0x0) [0x7c91e514] C:\WINDOWS\system32\kernel32.dll(WaitForSingleObject+0x12) [0x7c802542] C:\Ruby193\bin\msvcrt-ruby191.dll(rb_vm_bugreport+0xf9) [0x62e5c589] C:\Ruby193\bin\msvcrt-ruby191.dll(rb_name_err_mesg_new+0x17a) [0x62d3a7e2] C:\Ruby193\bin\msvcrt-ruby191.dll(rb_bug+0x2f) [0x62d3b4fb] C:\Ruby193\bin\msvcrt-ruby191.dll(rb_check_safe_str+0x1a4) [0x62dee168] [0x004011e6] C:\WINDOWS\system32\kernel32.dll(UnhandledExceptionFilter+0x1c7) [0x7c864191]

-- Other runtime information -----------------------------------------------

[NOTE] You may have encountered a bug in the Ruby interpreter or extension libraries. Bug reports are welcome. For details: http://www.ruby-lang.org/bugreport.html

This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.

If you think that this is not FXRuby error then I'll post it in ruby-lang site, just erase this, thanks!!!!

larskanis commented 12 years ago

It's a fxruby-bug, for sure. I can reproduce it on Linux, so I'll be able to debug it properly and will look at it in the next days.

larskanis commented 12 years ago

Hi Igor,

thanks for reporting this! There were actually two issues:

  1. The flag SPLASH_OWNS_ICON should not be used in Ruby. The garbage collector will free the icon, so this flag causes a double free, that results in a segfault. I pushed a patch that masks out the flag, now, so that it has no effect anymore.
  2. The garbage collection for FXSplashWindow did not work correctly at application exit. The object was double free'd, which results in a segfault as well. I pushed a patch that fixes it.

Please test the just uploaded fxruby-1.6.25.pre2.

damian-m-g commented 12 years ago

It's fixed, work fine, thank you so much! I will dare to make you a question related to your previous comment, please check this post, It will take you no more than one minute, I didn't have any answer since weeks... :

http://forums.pragprog.com/forums/53/topics/10776

larskanis commented 12 years ago

It took me 30 minutes to register and answer :)

So I'll release 1.6.25 with the fixes applied.