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

solana program deploy segfaults on macOS #33372

Closed
dmakarov opened this issue Sep 22, 2023 · 2 comments
Closed

solana program deploy segfaults on macOS #33372

dmakarov opened this issue Sep 22, 2023 · 2 comments

Comments

@dmakarov
Copy link
Contributor

Problem

Running solana program deploy command on macOS crashes with Segmentation fault: 11. This happens to solana built from source with the current top of the master branch, and only if built in release mode. The same source (of solana cli) built in debug mode works ok. The deployment is done to a local test validator.

For example:

$ solana program deploy --use-quic -k test.json -u localhost program.so
Segmentation fault: 11

Or in debugger

(lldb) run program deploy --use-quic -k test.json -u localhost program.so
Process 43727 launched: '~/.local/share/solana/install/active_release/bin/solana' (x86_64)
Process 43727 stopped
* thread #1, name = 'main', queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
    frame #0: 0x0000000100d054c8 solana`std::sys::common::thread_local::lazy::LazyKeyInner$LT$T$GT$::initialize::h95cc1ffe6c3fcbe6 + 696
solana`std::sys::common::thread_local::lazy::LazyKeyInner$LT$T$GT$::initialize::h95cc1ffe6c3fcbe6:
->  0x100d054c8 <+696>: movaps %xmm0, 0x150(%rbx)
    0x100d054cf <+703>: movaps -0xb0(%rbp), %xmm0
    0x100d054d6 <+710>: movaps %xmm0, 0x160(%rbx)
    0x100d054dd <+717>: addq   $0x10, %rbx
Target 0: (solana) stopped.

Proposed Solution

Debug and fix.

@KirillLykov KirillLykov self-assigned this Sep 22, 2023
@Lichtso
Copy link
Contributor

Lichtso commented Sep 25, 2023

Failed to load / store SIMD registers, which was caused by the stack pointer not being 16 byte aligned.
The fix for that just landed: #33394

@Lichtso Lichtso closed this as completed Sep 25, 2023
@norwnd
Copy link
Contributor

norwnd commented Oct 28, 2023

Hi @Lichtso, I'm currently observing similar issue on MacOS running latest master:

~/solana (master) » solana program write-buffer /Users/norwnd/solana-random-number-betting-game/solana-program/target/deploy/bpf_program_template.so
[1]    80589 segmentation fault  solana program write-buffer

I assume it already includes the fix you mentioned above, hence I'm raising it hoping you can take a look,

I'm quite new to Rust (and solana repo), but I managed to track the culprit down to fn create_ephemeral_keypair calling this line (just by using println!s and replacing it with hardcoded Mnemonic value):

let mnemonic = Mnemonic::new(MnemonicType::for_word_count(WORDS)?, Language::English);

I also can't reproduce this segfault with a simple unit-test:

    #[test]
    fn test_try_reproduce_segfault() {
        let (_, mnemonic, _) = create_ephemeral_keypair().expect("got error");
        assert_eq!("some phrase", mnemonic.phrase())
    }

and I'm not sure what to make of it, thoughts ?

Also, I think this segfault wasn't a thing ~1 month ago, I think I started observing it after ~roughly recent Mac update about a week ago (could be a Rust/OS issue then, googling didn't help though).

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

4 participants