1

I was going through the process of filling out the Solana Serialization Benchmarks and tried adding Bitcode as an option for serializing/deserializing accounts. However, whenever I compile and deploy my program locally with Bitcode included, the tests all fail.

Tracing it down it looks like the error is:

'Program BENCHVr3SC7dVDMtKVpwctjFNPBMrqvXn9JVACJg3KEb invoke [1]',
'Program is not deployed',
'Program BENCHVr3SC7dVDMtKVpwctjFNPBMrqvXn9JVACJg3KEb failed: invalid account data for instruction'

Confirming on the explorer with localhost, however, the program is very clearly deployed and executable. This leads me to guess that the Bitcode crate somehow includes code that doesn't properly translate into eBPF or the program is somehow corrupted.

Appreciate any insight into what the problem could be.

1 Answer 1

1

Edit: Removed previous answer entirely.

After spending some time looking at this, we found that the bitcode crate uses thread_local storage in order to minimize generated code at https://github.com/SoftbearStudios/bitcode/blob/235015870c564f6b2ca9c54cbe42e1426eb018de/src/pack_ints.rs#L240

This thread_local creates a separate .data section in the built program, whose title goes past the maximum size allowable by a Solana program, and fails deployment.

For this issue, the fix is to remove the thread_local code to ensure that the extra data section is not included.

More generally, the linker should probably catch this, and would likely be an easy fix.

4
  • To be clear, the program is definitely deployed. The only thing separating a successful test and an unsuccessful test is the inclusion of Bitcode as a dependency.
    – kwelliott
    Commented Aug 7 at 14:05
  • You'll need to provide more information in that case. I've added bitcode to a sample program, and it still runs no problem with platform tools v1.41. There is a function that blows the stack, but if it isn't used, it won't cause an issue: Error: Function _ZN7bitcode9histogram9histogram17hba2b12ca7218186fE Stack offset of 4096 exceeded max offset of 4096 by 0 bytes, please minimize large stack variables
    – Jon C
    Commented Aug 7 at 19:40
  • Here's the WIP repo where Bitcode being included results in failed tests. Standard Metaplex setup with details in the md files. github.com/metaplex-foundation/solana_serialization_benchmark/…
    – kwelliott
    Commented Aug 8 at 13:47
  • I also encountered the same problem with the Regex crate so I'm wondering if it has to do with both of them using alloc.
    – kwelliott
    Commented Aug 8 at 13:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.