Skip to content

No backtrace symbols on MacOS w/ Apple Silicon #577

Closed

Description

@ramosbugs

I'm building a Lambda function by invoking:

$ RUSTFLAGS="-C strip=none" cargo lambda build --arm64

I'm running on ARM64 MacOS:

$ uname -a
Darwin Ramos-M1 23.2.0 Darwin Kernel Version 23.2.0: Wed Nov 15 21:53:18 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6000 arm64

As expected, this produces a binary that appears to contain debug symbols:

$ file ../../target/lambda/bootstrap/bootstrap 
../../target/lambda/bootstrap/bootstrap: ELF 64-bit LSB pie executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 2.0.0, with debug_info, not stripped

However, all of the backtraces I generate via the backtrace crate look like:

 0: <unknown>    
 1: <unknown>    
...
31: <unknown>    
32: __libc_start_call_main    
33: __libc_start_main_impl

Panics with RUST_BACKTRACE=1 are similarly empty:

thread 'main' panicked at 'not yet implemented', src/lib.rs:173:5
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

I'm not sure if it's related, but when I build with --release, catch_unwind doesn't even catch the panics. They unwind past the catch and terminate the program. It's unclear if the issue described above is just an issue of missing debug symbols, or something deeper related to stack unwinding. Panics are caught in debug mode, however.

Interestingly, everything works fine when I directly build the Lambda via the Homebrew musl-cross toolchain:

$ export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-musl-gcc
$ cargo build --target aarch64-unknown-linux-musl --release

Even in release mode, the Lambda built with musl-cross both prints backtrace symbols and catches panics.

Any ideas?

Activity

  1. ramosbugs commented on Dec 13, 2023

    @ramosbugs
    Author

    Oh, I should note that I'm invoking the Lambda using sam local start-api from the AWS SAM CLI, though I don't think any differences between the two Docker images should matter here.

  2. calavera commented on Dec 13, 2023

    @calavera
    Collaborator

    This is because the linker that Cargo Lambda uses by default is probably not keeping that information. See https://www.cargo-lambda.info/guide/cross-compiling.html

    I'm not sure if it's related, but when I build with --release, catch_unwind doesn't even catch the panics. They unwind past the catch and terminate the program.

    this is expected. See https://www.cargo-lambda.info/guide/release-optimizations.html#panic-behavior

  3. ramosbugs commented on Dec 13, 2023

    @ramosbugs
    Author

    This is because the linker that Cargo Lambda uses by default is probably not keeping that information. See https://www.cargo-lambda.info/guide/cross-compiling.html

    Would https://github.com/rust-cross/cargo-zigbuild be the appropriate project to open a bug for this behavior, or is the linker part of another component?

    this is expected. See https://www.cargo-lambda.info/guide/release-optimizations.html#panic-behavior

    I missed that in the docs, thanks! 🙏

  4. calavera commented on Dec 14, 2023

    @calavera
    Collaborator

    Would https://github.com/rust-cross/cargo-zigbuild be the appropriate project to open a bug for this behavior, or is the linker part of another component?

    Yes, cargo-zigbuild is the right place to have a more detailed conversation about that.

  5. ramosbugs commented on Dec 14, 2023

    @ramosbugs
    Author

    Thanks, I opened an issue there.

  6. locked as resolved and limited conversation to collaborators on Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions