pkulchenko / ZeroBraneStudio

Lightweight Lua-based IDE for Lua with code completion, syntax highlighting, live coding, remote debugger, and code analyzer; supports Lua 5.1, 5.2, 5.3, 5.4, LuaJIT and other Lua interpreters on Windows, macOS, and Linux
http://studio.zerobrane.com/
Other
2.6k stars 519 forks source link

Fatal error running from ArchLinux packages #995

Closed alerque closed 4 years ago

alerque commented 5 years ago

I'm just adopted the ZBS packages that have been out of date in ArchLinux for some time and am trying to get them opperable again. I changed the wxLua package to your fork (git HEAD) and bumped the studio version to 1.80. This obsoleted (or at least broke the patches for) most of the workarounds that had been applied. The only one that really still make sense to me is fixing the call to the system's Lua executable in the main /usr/bin/zbstudio file.

However I'm not getting anywhere trying to actually run it. On launch I am greeted with this:

./src/common/artprov.cpp(220): assert "client.Last() == wxT('C')" failed in GetBitmap(): invalid 'client' parameter /usr/bin/zbstudio: line 6: 26059 Trace/breakpoint trap (core dumped) /usr/bin/lua src/main.lua zbstudio -cwd "$CWD" "$@"

Do you have any suggestions for what I might be looking for? It would be nice to have working ArchLinux packages again.

pkulchenko commented 5 years ago

@alerque, thank you for the report! I'll have to give it a try in my ArchLinux VM to see what may be going on. The error looks strange though, as it fails on the assert with the comment "safety-check against writing client,id,size instead of id,client,size:", which shouldn't happen.

There is only one place where GetBitmap seem to be used. Can you try applying the following patch to see if it makes any difference:

diff --git a/src/editor/package.lua b/src/editor/package.lua
index 0878dc83..265bbcca 100644
--- a/src/editor/package.lua
+++ b/src/editor/package.lua
@@ -965,7 +965,7 @@ function ide:GetBitmap(id, client, size)
         file = img:Rescale(width, width, wx.wxIMAGE_QUALITY_NEAREST)
       end
     end
-    if not file then return wx.wxArtProvider.GetBitmap(id, client, size) end
+    -- if not file then return wx.wxArtProvider.GetBitmap(id, client, size) end
   end
   local icon = icons[file] or iconFilter(wx.wxBitmap(file), self.config.imagetint)
   icons[file] = icon
alerque commented 5 years ago

Sure. I applied that patch to the package an build time, installed the resulting package, and was greeted with a different error:

/usr/bin/lua: src/editor/package.lua:891: wxLua: Function call has invalid argument 1 on method 07.

Function called: 'wxBitmap(nil)'
01. wxBitmap::wxBitmap(table)
02. wxBitmap::wxBitmap(string, number, number, number)
03. wxBitmap::wxBitmap(table, number, number, number)
04. wxBitmap::wxBitmap(wxImage [, number])
05. wxBitmap::wxBitmap(string [, integer])
06. wxBitmap::wxBitmap(number, number [, number])
07. wxBitmap::wxBitmap(wxBitmap)
08. wxBitmap::wxBitmap()
stack traceback:
        [C]: in field 'wxBitmap'
        src/editor/package.lua:891: in method 'GetBitmap'
        src/editor/package.lua:883: in method 'GetBitmap'
        src/editor/gui.lua:137: in local 'createToolBar'
        src/editor/gui.lua:678: in main chunk
        [C]: in function 'dofile'
        src/main.lua:582: in main chunk

I suspect this probably has to do with Lua search paths synce the Arch package is trying to use the system's Lua installation, but that's just a gut level feeling.

pkulchenko commented 5 years ago

It's a deficient patch (as no "default" bitmap is going to be provided). This should be a better one:

diff --git a/src/editor/package.lua b/src/editor/package.lua
index 0878dc83..d3f52403 100644
--- a/src/editor/package.lua
+++ b/src/editor/package.lua
@@ -965,7 +965,7 @@ function ide:GetBitmap(id, client, size)
         file = img:Rescale(width, width, wx.wxIMAGE_QUALITY_NEAREST)
       end
     end
-    if not file then return wx.wxArtProvider.GetBitmap(id, client, size) end
+    if not file then return wx.wxBitmap(size:GetWidth(), size:GetHeight()) end
   end
   local icon = icons[file] or iconFilter(wx.wxBitmap(file), self.config.imagetint)
   icons[file] = icon

Thank you for checking it!

alerque commented 5 years ago

We appear to have passed that hurdle. On to another one? Or are we solving the wrong problem by suppressing symptoms?

/usr/bin/lua: src/editor/package.lua:466: wxLua: Unable to call an unknown method 'ReplaceTargetRaw' on a 'wxS
tyledTextCtrl' type.
stack traceback:
        [C]: in metamethod '__index'
        src/editor/package.lua:466: in method 'CreateStyledTextCtrl'
        src/editor/gui.lua:588: in local 'createBottomNotebook'
        src/editor/gui.lua:681: in main chunk
        [C]: in function 'dofile'
        src/main.lua:582: in main chunk
        [C]: in ?
pkulchenko commented 5 years ago

@alerque, it's because of the slight difference between wxlua build for ZBS and the one you built from the repository; we were just discussing this in pkulchenko/wxlua/issues/21, which I plan to fix shortly in wxlua, but it was already fixed in ZBS, just post-1.80.

Can you replace the offending line with if not self:IsValidProperty(editor, "ReplaceTargetRaw") then check?

alerque commented 5 years ago

I would have expected your fork of wxLua to be the "one for ZBS". Coming at this project from the outside I'm honestly really confused what is what here.

I just tried the additional patch, but I'm on a different computer than I was yesterday and something more fundamental is wrong — this time zbstudio is throwing a lua segfault. I'm going to have to look at yesterday's system another time to determine why the packaging is different.

Is wxlua supposed to be providing a /usr/bin/lua? That seems wrong to me.

pkulchenko commented 5 years ago

@alerque,

I would have expected your fork of wxLua to be the "one for ZBS". Coming at this project from the outside I'm honestly really confused what is what here.

It wasn't. I just forked wxlua and picked up support for it, as it wasn't maintained, but I didn't want to merge ZBS-specific patches into it, as I wasn't sure that no other project gets affected by them. As the result, some of the platforms that build wxlua from scratch need special care to run ZBS on top of their binaries. ZBS does support those as well, but there were couple of incompatible changes that only got fixed after 1.80 was released (that's why you ran into those issues).

I also brought wxlua up-to-date with wxwidgets master branch and applied several of the changes that were previously handled separately, so https://github.com/pkulchenko/wxlua/tree/wxwidgets312 branch should be good for your purposes. I'm still not sure why ArtProvider.GetBitmap call throws an assertion nor why it even gets to that point, as it's not being triggered for me; you shouldn't see the it assuming the bitmap images are available in the zbstudio/res folder.

pkulchenko commented 4 years ago

@alerque, can you check with the new release? It's using wxlua 3.0.0.8, which includes all the changes we discussed. I'm unsure about ArtProvider.GetBitmap throwing that exception about invalid client, but everything else in the ticket has been addressed.

alerque commented 4 years ago

@alerque, can you check with the new release?

What release? Is 1.90 tagged? Or wxlua 3.0.0.8? I don't see either of them. Or do you mean a build from git HEAD?

pkulchenko commented 4 years ago

Either one. 1.90 is already tagged and published. Thank you.

alerque commented 4 years ago

This problem is resolved now on Arch Linux now with zbstudio 1.90 and wxlua 3.0.0.8. I'm still using the wxArtProvider→wxBitmap patch, I'm not actually sure what that's about.

pkulchenko commented 4 years ago

@alerque, sounds good; thank you for the update! I'd be curious to see if it works without the wxArtProvider patch (as I can't explain why it may be needed), but I understand if you don't want to spend time on this.