shoes / shoes3

a tiny graphical app kit for ruby
http://walkabout.mvmanila.com
Other
179 stars 19 forks source link

Application crash when an alert or yes/no message is closed. #432

Closed dredknight closed 5 years ago

dredknight commented 5 years ago

Hey Cecil,

I decided to release a new version of my skillwheel app but during some QA-ing with 3.3.7 r3301 I found out that there is some issue when alert and ask are called. Basically what happens is that the Alert /Ask window pops and when I click "Close" the whole Shoes app quits.

Unfortunately I cannot simulate the issue when I put them into a simple example. I will try some more and let you know if I manage to do it though but if you have an idea where it comes from will be nice :(.

ccoupe commented 5 years ago

Do you get a stack dump when using cshoes to run the offending script? It might be helpful.

dredknight commented 5 years ago

How to get a stack dump could you give me some guide how to activate it while using the main.rb of the app?

ccoupe commented 5 years ago

Sounds like it's just silently quitting and not crashing. You can modify your script to catch all exceptions not caught elsewhere and puts a ruby backtrace - probably won't help.

dredknight commented 5 years ago

That is exactly what happens. Both the app and the debug window disappear. Task manager process dies along them.

ccoupe commented 5 years ago

Obviously, it (something) is calling the exit or Shoes.quit or possibly quit . Shoes doesn't allow trapping the ruby at_exit() - too bad in this case. It can also go away if Gtk3 breaks out of the run loop but I don't know how to do that from Shoes. What's happening in the dialogs? Any external shelled-to commands or IO ?

dredknight commented 5 years ago

Alright. I stripped 50kb of code so I can find the culprit. Here it goes... it is not what you may have expected though...

This does not work.

Shoes.app(title: "111111111111111111111111111111111111111111111111111111111" ) do

    @pic2 = image "#{DIR}/static/shoes-icon.png"
    @pic2.click do
        alert "yes"
    end
end

This works

Shoes.app(title: "11111111111111111111111111111111111111111111111111111111" ) do

    @pic2 = image "#{DIR}/static/shoes-icon.png"
    @pic2.click do
        alert "yes"
    end
end

The difference is that the second example has one less character as an application title.... If you pass than length alerts and yes/no questions break.

I tested it on my full app (51kb code) and as soon as I reduce the length of the title below that count all stuff work.

ccoupe commented 5 years ago

Excellent ! I can reproduce it on linux too with this additional message on the console

*** stack smashing detected ***: minlin/shoes terminated
Aborted

Odds are high it's a buffer overflow type of bug or other C level mistakes.

ccoupe commented 5 years ago

Indeed. It was a too small buffer. There's is a new 3.3.7 at the beta site with a larger buffer that should get you going.