Problem loanding png files on wxWidgets-3.1.4

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
dkaip
Super wx Problem Solver
Super wx Problem Solver
Posts: 334
Joined: Wed Jan 20, 2010 1:15 pm

Problem loanding png files on wxWidgets-3.1.4

Post by dkaip »

Hello. When i am trying compiler says that it can not recognize the png file.

Code: Select all

    wxImage image;
    image.LoadFile(wxT("a_file.png"));
But if i add wxInitAllImageHandlers(); then program crashes.

Code: Select all

    wxInitAllImageHandlers();
    wxImage image;
    image.LoadFile(wxT("/home/a/Επιφάνεια εργασίας/163.png"));
I am using wxWidgets-3.1.4 on Linux Mint. Is problem of 3.1.4?
Thank you.
Jim
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: Problem loanding png files on wxWidgets-3.1.4

Post by PB »

The compiler very likely has no say in this, the error comes either from wxWidgets or libpng (I assume that on Linux you use the system libpng, not the one shipped with wxWidgets).

Are you sure the path encoding is not the issue, i.e., does it still crash even when the path contains only 7-bit ASCII characters or you pass the string you obtained e.g. from wxFileDialog::GetFileName()?

Anyway, you should step into the code and see where exactly (if not why) it crashes or at least get the crash stack call list from the debugger.
dkaip
Super wx Problem Solver
Super wx Problem Solver
Posts: 334
Joined: Wed Jan 20, 2010 1:15 pm

Re: Problem loanding png files on wxWidgets-3.1.4

Post by dkaip »

The compiler very likely has no say in this, the error comes either from wxWidgets or libpng (I assume that on Linux you use the system libpng, not the one shipped with wxWidgets).
There is no problem with libpng because i have the exaxt same code using wxWidgets-3.0.5 and there is no problem.
Are you sure the path encoding is not the issue, i.e., does it still crash even when the path contains only 7-bit ASCII characters or you pass the string you obtained e.g. from wxFileDialog::GetFileName()?
Never have problem with that, because the crashes happens only with png files.
Anyway, you should step into the code and see where exactly (if not why) it crashes or at least get the crash stack call list from the debugger.
If there is the wxInitAllImageHandlers(); process terminated with status -1 (0 minute(s), 0 second(s))
If not program say unknown image data format.
I send an image.
Thank you
Jim
Attachments
a.png
a.png (12.55 KiB) Viewed 997 times
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: Problem loanding png files on wxWidgets-3.1.4

Post by PB »

Firstly, I still do not know if it happens for all PNG files or only for some.
dkaip wrote: Tue Nov 10, 2020 7:03 am If there is the wxInitAllImageHandlers(); process terminated with status -1 (0 minute(s), 0 second(s))
If not program say unknown image data format.
Well, this is expected. If no image handler is found then the file format is not recognized and that's it. Otherwise the crash comes from the image handler code when loading the file.
dkaip wrote: Tue Nov 10, 2020 7:03 am I send an image.
There is no image attached (except a rather useless screenshot of the error).

Why did you not try to see where the problem comes from using the debugger, either stepping into the code or looking at the call stack? The information you provide is insufficient.

Did you at least verify that applications using 3.0.5 and 3.1.4 use the exact same version of libpng?

Just to be sure, did you try if the crash happens also when loading image with the image sample?
dkaip
Super wx Problem Solver
Super wx Problem Solver
Posts: 334
Joined: Wed Jan 20, 2010 1:15 pm

Re: Problem loanding png files on wxWidgets-3.1.4

Post by dkaip »

My code is at the begging ..

Code: Select all

    wxInitAllImageHandlers();
    wxImage image;
    image.LoadFile(wxT("/home/a/163.png"));
The debugger ...
...........
[debug][Thread debugging using libthread_db enabled]
[debug]Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Child process PID: 7697

[debug][New Thread 0x7fffeabe0700 (LWP 7697)]
[debug][New Thread 0x7fffea3df700 (LWP 7698)]
[debug]32 ../setjmp/longjmp.c: Δεν υπάρχει τέτοιο αρχείο ή κατάλογος.
[debug]Thread 1 "la" received signal SIGSEGV, Segmentation fault.
[debug]__longjmp_chk (env=0x0, val=1) at ../setjmp/longjmp.c:32
[debug]>>>>>>cb_gdb:
[debug]> info frame
[debug]Stack level 0, frame at 0x7fffffffd740:
[debug] rip = 0x7ffff3907fa0 in __longjmp_chk (../setjmp/longjmp.c:32); saved rip = 0xa6c600
[debug] called by frame at 0x7fffffffd750
[debug] source language c.
[debug] Arglist at 0x7fffffffd720, args: env=0x0, val=1
[debug] Locals at 0x7fffffffd720, Previous frame's sp is 0x7fffffffd740
[debug] Saved registers:
[debug] rbx at 0x7fffffffd728, rbp at 0x7fffffffd730, rip at 0x7fffffffd738
[debug]>>>>>>cb_gdb:

Cannot open file: ../setjmp/longjmp.c
At ../setjmp/longjmp.c:32
I have send the image and call stack image.
Did you at least verify that applications using 3.0.5 and 3.1.4 use the exact same version of libpng?
I don’t know how to check that.
Just to be sure, did you try if the crash happens also when loading image with the image sample?
I have put the code bellow but nothing ...

Code: Select all

// In your App class that derived from wxApp
void myProject::OnUnhandledException()
{
    try
    {
        throw;
    }
    catch(std::exception &e)
    {
        wxMessageBox( e.what(),"C++ Exception Caught",wxCENTER);
    }
    return ;   // continue on. Return false to abort program
}


bool myProject::OnExceptionInMainLoop()
{
    try
    {
        throw;
    }
    catch(std::exception &e)
    {
        wxMessageBox( e.what(),"C++ Exception Caught",wxCENTER);
    }
    return true;   // continue on. Return false to abort program
}
Thank you
Jim
Attachments
163.png
163.png (53.13 KiB) Viewed 951 times
164.png
164.png (42.17 KiB) Viewed 951 times
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: Problem loanding png files on wxWidgets-3.1.4

Post by PB »

FWIW, I can open the 163.png image in the image sample running on Linux Mint 20 under VirtualBox just fine:
image-sample-mint.png
So it would seem wxWidgets version (3.1.4 vs 3.0.5) may not be at fault here?

AFAICT, the libpng I have is version 1.6.37 (libpng16.so.1637). However, from your call stack screenshot it seems that your libpng is v1.2?

I am afraid that I am out of options, perhaps someone knowledgeable about Linux can actually help.
Post Reply