Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segmentation Fault #46

Open
adamstambouli opened this issue Feb 24, 2024 · 10 comments
Open

Segmentation Fault #46

adamstambouli opened this issue Feb 24, 2024 · 10 comments

Comments

@adamstambouli
Copy link

Hey!

I'm getting a segmentation fault on a M1 Macbook Pro running Sonoma 14.0.

pigmnts test.png -xrd
Creating a palette of 5 colors from test.png
⠸
[1]    16785 segmentation fault  pigmnts test.png -xrd

Any logs I can check to see how to fix this?

@blenderskool
Copy link
Owner

@adamstambouli Are you using one of the binaries from releases?
There is no binary for M1 chips(Ref), so either you'll have to compile from source, or we can update the build CI with M1 as another target. Would you be interested in contributing this change?

@adamstambouli
Copy link
Author

@blenderskool oh gotcha! Yes I'm happy to contribute although I'm not familiar with Rust.

Do you have any advice/tips on which changes I should be making?

@blenderskool
Copy link
Owner

I don't think it should require any rust code changes. Try the following steps:

  1. Build the binary on your local M1 machine by cloning the project and running cargo build --release. This requires rust to be installed locally. If the binary works perfectly, we can add it in our CI config.
  2. Just add another entry for macOS on arm here. We'll need macos-14 from this list here to build for M1 chips.
    include:
    - os: ubuntu-18.04
    artifact_name: pigmnts
    asset_name: pigmnts-linux-18-04-amd64
    - os: ubuntu-16.04
    artifact_name: pigmnts
    asset_name: pigmnts-linux-16-04-amd64
    - os: macos-latest
    artifact_name: pigmnts
    asset_name: pigmnts-macos-amd64

@adamstambouli
Copy link
Author

adamstambouli commented Feb 25, 2024

So the good news is that building the binary runs successfully on Apple Silicon. I used:

cargo build --release --target aarch64-apple-darwin

Bad news is that the segfault still there:

./target/aarch64-apple-darwin/release/pigmnts ~/Downloads/test.png
Creating a palette of 5 colors from /Users/xxx/Downloads/test.png
⠹
[1]    20568 segmentation fault  ./target/aarch64-apple-darwin/release/pigmnts ~/Downloads/test.png

It's possible this is an Apple Silicon issue since Rust doesn't fully support it as a target: rust-lang/rust#73908

@blenderskool
Copy link
Owner

blenderskool commented Feb 25, 2024

Hmm, could you share the image file you are using? I'll test it on my amd64 machine to see if it's an issue with our code.

@adamstambouli
Copy link
Author

Yeah no problem, here it is.

pigmnts.zip

@blenderskool
Copy link
Owner

@adamstambouli Sorry, I was asking for the the image file you were using. I'll see if there's some edge case that went unhandled with the image you had used.

@adamstambouli
Copy link
Author

oh 😆 here are a few sample images that cause segfaults: pigmnts-sample-images.zip

pigmnts arsenal-away-23-24.webp
Creating a palette of 5 colors from arsenal-away-23-24.webp
⠹
[1]    38020 segmentation fault  pigmnts arsenal-away-23-24.webp
pigmnts united-third-23-24.png
Creating a palette of 5 colors from united-third-23-24.png
⠹
[1]    38063 segmentation fault  pigmnts united-third-23-24.png
pigmnts en.wikipedia.org_wiki_Liverpool_F.C..png
Creating a palette of 5 colors from en.wikipedia.org_wiki_Liverpool_F.C..png
⠋
[1]    38250 segmentation fault  pigmnts en.wikipedia.org_wiki_Liverpool_F.C..png

@blenderskool
Copy link
Owner

@adamstambouli Seems like this is an M1 specific issue since all the images worked fine on my x64 machine. Yet to build on M1 and test it.

@adamstambouli
Copy link
Author

@blenderskool thanks for investigating! Please feel free to triage this issue as you wish - it's ok if you close it and add M1 support to the roadmap if others are interested in the functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants