Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

UPDATE: Problem Installing Perl-Tk on macOS Monterey (12.6) with Apple M1 chip

by cmv (Chaplain)
on Oct 05, 2022 at 17:35 UTC ( [id://11147262]=note: print w/replies, xml ) Need Help??


in reply to Problem Installing Perl-Tk on macOS Monterey (12.6) with Apple M1 chip

UPDATE: I created my own private copy of basic.t and added some stderr debugging statements, then tried running it by hand from the PNG directory. Ran it many times, and it mostly fails with a segmentation fault, but it also will sometimes hang as I said before. Here is an example of when it segfaults:
$ cd /Users/cmv/.cpan/build/Tk-804.036-0/PNG $ /opt/homebrew/Cellar/perl/5.36.0/bin/perl -w t/cmv.t 1..5 ok 1 - use Tk::PNG; Photo 1 zsh: segmentation fault /opt/homebrew/Cellar/perl/5.36.0/bin/perl -w +t/cmv.t

Here are some relavent lines from my cmv.t file

... use_ok('Tk::PNG'); my $file = (@ARGV) ? shift : "$FindBin::RealBin/../pngtest.png"; my $mw = MainWindow->new; $mw->geometry('+10+10'); $mw->update; #### Added by --cmv sleep 10; { print STDERR "Photo 1\n"; #### Added by --cmv my $image = $mw->Photo('-format' => "png", -file => $file); print STDERR "Photo 2\n"; #### Added by --cmv ok($image, "Loaded PNG image from $file"); print STDERR "Photo 3\n"; #### Added by --cmv $mw->Label(-image => $image)->pack; print STDERR "Photo 4\n"; #### Added by --cmv $mw->update; print STDERR "Photo 5\n"; #### Added by --cmv } ...

Note 1: The $mw->update; line does cause the Tk mainwindow to show up on my screen!!!

Note 2: The problem seems to be loading the PNG photo. More digging needed here.

Many thanks to all who have provided pointers and help!

-Craig

Replies are listed 'Best First'.
Re: UPDATE 2: Problem Installing Perl-Tk on macOS Monterey (12.6) with Apple M1 chip
by cmv (Chaplain) on Oct 07, 2022 at 14:59 UTC
    I have verified that this is only an issue with the PNG code provided as part of pTk. I was able to manually run tests on all the rest of the pTk code, which was almost 100% successful, but have not yet had the time to nail down the specific cause of this PNG issue.

    Here is where I'm currently at:

    The offending line, causing the segfault, in the basic.t test file is:

    my $image = $mw->Photo('-format' => "png", -file => $file);
    Where:
    file="~/.cpan/build/Tk-804.036-0/PNG/t/../pngtest.png"

    When a segmentation fault occurs on a Mac, a *.ips file is created in ~/Library/Logs/DiagnosticReports providing more details on the fault. Stack frame analysis from this data yields:

    "frames":[
    {"imageOffset":9468,"symbol":"_longjmp","symbolLocation":72,"imageIndex":0}, {"imageOffset":18446639227543793010,"imageIndex":1}, {"imageOffset":166568,"symbol":"png_error","symbolLocation":420,"imageIndex":2}, {"imageOffset":91072,"symbol":"png_create_read_struct_2","symbolLocation":636,"imageIndex":2}, {"imageOffset":90424,"symbol":"png_create_read_struct","symbolLocation":60,"imageIndex":2}, {"imageOffset":10552,"symbol":"ChnReadPNG","symbolLocation":112,"imageIndex":2}, {"imageOffset":419820,"symbol":"ImgPhotoConfigureMaster","symbolLocation":1176,"imageIndex":3}, {"imageOffset":398084,"symbol":"ImgPhotoCreate","symbolLocation":204,"imageIndex":3}, {"imageOffset":366856,"symbol":"Tk_ImageObjCmd","symbolLocation":1664,"imageIndex":3}, {"imageOffset":88836,"symbol":"Call_Tk","symbolLocation":624,"imageIndex":3}, {"imageOffset":133540,"symbol":"XStoImage","symbolLocation":608,"imageIndex":3}, {"imageOffset":752088,"symbol":"Perl_pp_entersub","symbolLocation":1696,"imageIndex":4}, {"imageOffset":712144,"symbol":"Perl_runops_standard","symbolLocation":32,"imageIndex":4}, {"imageOffset":157920,"symbol":"S_run_body","symbolLocation":116,"imageIndex":4}, {"imageOffset":157800,"symbol":"perl_run","symbolLocation":648,"imageIndex":4}, {"imageOffset":15952,"symbol":"main","symbolLocation":180,"imageIndex":5}, {"imageOffset":20620,"symbol":"start","symbolLocation":520,"imageIndex":6}
    As you can see we did hit png_error() before heading to imagIndex(), then to _longjmp, which I'm guessing is the cause of the segfault.

    Since I'm not currently using PNG images for anything in my code, I just stubbed out the two test files and installed pTk via CPAN as you normally would. Everything else seems to be working fine.

    I would like to eventually figure out why this code segfaults on macOS Monterey (12.6) with Apple M1 chip, and feedback to the PNG group on what needs to be fixed.

    Any suggestions on what to try next would be welcome!

    Thanks

    -Craig

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11147262]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-04-24 00:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found