Code::Blocks Forums

User forums => Help => Topic started by: aphirst on December 17, 2018, 01:26:19 am

Title: Building C::B on Arch Linux - assert "image.IsOk()" failed in wxBitmap()
Post by: aphirst on December 17, 2018, 01:26:19 am
I've already reported this as a "bug" at https://sourceforge.net/p/codeblocks/tickets/775/ but since so far no-one else seems to be able to reproduce the problem, and since it doesn't seem especially consistent for me either, I think it makes sense to try to slog this one out on the forums rather than in a SF ticket.

I'm trying to build C::B from svn on my Arch Linux machine using the various -unix workspaces provided. I (now) have no issues using the bootstrap+configure+make approach, which I can use (in conjunction with a PKGBUILD) to make an installable package, but I also want to generate some "portable"-style builds as seems to be the intended output from these workspaces.

Essentially, as far as I'm concerned, I'm doing nothing exotic, and am following the instructions each time from a completely clean C::B profile, and yet my resulting binaries by this approach (regardless of which wx version I choose) all suffer from the same issue.

How I built C::B

How I produce the bug

The error messages were something like this:
Code
./src/gtk/bitmap.cpp(627): assert "image.IsOk()" failed in wxBitmap(): invalid image
./src/gtk/dcclient.cpp(1832): assert "IsOk()" failed in SetTextForeground(): invalid window dc
./src/common/image.cpp(1746): assert "IsOk()" failed in GetHeight(): invalid image
./src/common/image.cpp(1739): assert "IsOk()" failed in GetWidth(): invalid image
./src/gtk/bitmap.cpp(924): assert "IsOk()" failed in GetWidth(): invalid bitmap
./src/gtk/bitmap.cpp(917): assert "IsOk()" failed in GetHeight(): invalid bitmap
./src/gtk/dcclient.cpp(1088): assert "bitmap.IsOk()" failed in DoDrawBitmap(): invalid bitmap
./src/gtk/dcclient.cpp(1088): assert "bitmap.IsOk()" failed in DoDrawBitmap(): invalid bitmap

On advice from Obfuscated, I tried launching my C::B binary in gdb (by prepending "gdb" to the final line in run.sh), and setting a breakpoint for "cbLoadBitmap", from which I learned the following:


I initially thought I'd devised a workaround based on clearing parts of the build space, but I am no longer able to reproduce this, so am still stuck with the issue. As mentioned, I don't get this issue when building via (bootstrap+)configure+make, so I'm inclined to believe that there's something flakey about the .cbp or .workspace files themselves, as opposed to it being an issue with my system configuration.

If anyone can suggest any further modes of enquiry, I'd really appreciate it. I'm at a bit of a loss, and given how long it takes each build, I'm starting to get driven a little bit mad by it.
Title: Re: Building C::B on Arch Linux - assert "image.IsOk()" failed in wxBitmap()
Post by: BlueHazzard on December 17, 2018, 01:17:02 pm
Quote
playing around with gdb it seems that C::B is repeatedly trying to access "breakpoint-" related PNG files from the "share/codeblocks/manager_resources.zip" archive - notice that those were some of the UI icons which don't render for me
Does the images exist? Are the paths valid?

Have you tried to kill codeblocks if the Assert dialog pops up with gdb and then go the call stack upwards to see why the image is not valid? You can use codeblocks to debug codeblocks:
Open the Codeblocks workspace, and start the debugger with the red arrow. Then select the "src" target. Codeblocks will open, then you do your things until you get the assert dialog. Hit "Ok" in the assert dialog. The other codeblocks instance should come to front with a call stack in the Debugger->Debugging windows->Call stack (if not make one step with F7 or Debug->One line).
Now you can double click in the stack window to switch to the selected frame. Then you can inspect the variables (specially the img variable) that caused the assert. Check why it is not valid...

I somehow can not reproduce this on mint... Will have to set up arch to investigate this, but i have no time at the moment -.-'
Title: Re: Building C::B on Arch Linux - assert "image.IsOk()" failed in wxBitmap()
Post by: Huki on December 17, 2018, 08:10:40 pm
I can confirm this bug when building codeblocks using the provided project file(s) on Arch Linux. The images do exist, all paths are valid, but they show up / disappear / reappear, with the same sequence of steps as described by the OP.

I worked around the bug by building codeblocks with 'configure / make / make install'. In this case it works fine (been using this custom build for a couple of months now).
Title: Re: Building C::B on Arch Linux - assert "image.IsOk()" failed in wxBitmap()
Post by: aphirst on December 17, 2018, 08:34:35 pm
@Huki - Thanks for confirming! I'm not insane after all!

@BlueHazzard - I've not had as much time today for debugging as I'd hoped, but what I have been able to do is make a Google Drive folder with the following contents:

The link is: https://drive.google.com/open?id=1p6_cDMnmAyq_AKoDyr859IzuQgpGWX-O
Title: Re: Building C::B on Arch Linux - assert "image.IsOk()" failed in wxBitmap()
Post by: BlueHazzard on December 17, 2018, 10:31:30 pm
Do you have tried to configure/build codeblocks with a --prefix option and then make a diff with the devel build? There has to be some difference...

[Edit:] checking why IsOk fails would also help, and probably be more easy...
Title: Re: Building C::B on Arch Linux - assert "image.IsOk()" failed in wxBitmap()
Post by: Huki on December 25, 2018, 08:11:46 pm
Below is cbLoadBitmap() from sdk/globals.cpp:
Code
wxBitmap cbLoadBitmap(const wxString& filename, wxBitmapType bitmapType)
{
    // cache this, can't change while we 're running :)
    static bool oldCommonControls = !UsesCommonControls6();

    wxImage im;
    wxFileSystem* fs = new wxFileSystem;
    wxFSFile* f = fs->OpenFile(filename);
    if (f)
    {
        wxInputStream* is = f->GetStream();
        im.LoadFile(*is, bitmapType);
        delete f;
    }
    delete fs;
    if (oldCommonControls && im.HasAlpha())
        im.ConvertAlphaToMask();

    return wxBitmap(im);
}

When the bug happens, the call fs->OpenFile(filename) returns NULL. This means the empty wxImage im is passed as-is to wxBitmap(im). This triggers all those wxBitmap asserts.

There is something wrong with the way wxFileSystem::OpenFile() tries to resolve relative file paths. When I manually prepend my current working directory to filename, the call always succeeds. It's relative paths that behave oddly.

Again, there is no such problem when CB is build using configure / make.
Title: Re: Building C::B on Arch Linux - assert "image.IsOk()" failed in wxBitmap()
Post by: oBFusCATed on December 25, 2018, 09:37:48 pm
You can build a debug version of your wxgtk and try to debug it. It doesn't happen with my version in gentoo...