apple / swift-crypto

Open-source implementation of a substantial portion of the API of Apple CryptoKit suitable for use on Linux platforms.
https://apple.github.io/swift-crypto
Apache License 2.0
1.43k stars 151 forks source link

CCryptoBoringSSL_ex_data.h:207:8: note: definition has no member 'ctx' #243

Closed diegotl closed 4 days ago

diegotl commented 1 week ago

New Issue Checklist

Expected behavior

Build to succeed

Actual behavior

Since yesterday evening when I resolve package and build a certain Vapor swift package, this error pops up:

Building for production...
/usr/include/openssl/crypto.h:181:19: error: 'crypto_ex_data_st::ctx' from module 'OpenSSL' is not present in definition of 'struct crypto_ex_data_st' in module 'CCryptoBoringSSL'
    OSSL_LIB_CTX *ctx;
                  ^
/home/projects/app/.build/checkouts/swift-crypto/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_ex_data.h:207:8: note: definition has no member 'ctx'
struct crypto_ex_data_st {

Seems to be related to 3.5.0 release, because I see no issues when forcing 3.4.0 in Package.swift.

Steps to reproduce

Happens in a private repo but I can provide access upon request.

If possible, minimal yet complete reproducer code (or URL to code)

swift package resolve swift package update swift build -c release

Swift Crypto version/commit hash

3.5.0 / 33f65a3cbc52f8c19295723af9cbecc2195484e1

Environment

Stand in the root of the repo and run ./scripts/environment.sh and paste the output below

Swift version: Swift version 5.10.1 (swift-5.10.1-RELEASE) Target: x86_64-unknown-linux-gnu\nUnix version: Linux pacotevicio-ash-1 5.15.0-113-generic #123-Ubuntu SMP Mon Jun 10 08:16:17 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux\n
MahdiBM commented 1 week ago

We're also having similar errors in Penny's tests: https://github.com/vapor/penny-bot/pull/208

simonjbeaumont commented 5 days ago

@MahdiBM I'll try and take a look at this tomorrow. Looks like there are a couple of issues caused by our BoringSSL vendoring in the latest release, for which we needed to drop the @_implementationOnly.

simonjbeaumont commented 5 days ago

@MahdiBM Looking at your CI output, I think your issue may not be the same as that in this issue description. You have these failures:

/__w/penny-bot/penny-bot/.build/checkouts/swift-crypto/Sources/CCryptoBoringSSL/include/CCryptoBoringSSL_x509.h:2714:1: error: 'sk_X509_ATTRIBUTE_delete_if' has different definitions in different modules; definition in module 'CCryptoBoringSSL' first difference is function body
DEFINE_STACK_OF(X509_ATTRIBUTE)
...

This should be addressed by #245. I'll ping you when we release that one and we can use this issue to investigate the OP issue.

simonjbeaumont commented 5 days ago

@diegotl It's not clear that #245 will fix your issue. Are you able to provide a minimal reproducer and/or access to your project and steps to reproduce the failure?

simonjbeaumont commented 5 days ago

@MahdiBM https://github.com/apple/swift-crypto/releases/tag/3.5.1 should hopefully resolve your penny build.

diegotl commented 4 days ago

@simonjbeaumont I think it's not necessary because I just tried 3.5.1 and it fixes the issue, thank you very much!

simonjbeaumont commented 4 days ago

@diegotl thanks for confirming, and that's good to hear.

simonjbeaumont commented 4 days ago

I have chatted with @MahdiBM offline and 3.5.1 wasn't enough to fix for penny https://github.com/vapor/penny-bot/actions/runs/9767425786/job/26962669715?pr=211.

diegotl commented 4 days ago

That's interesting, what I did was set 3.5.1 and built the module myself on Ubuntu (same as I was doing when I opened the issue) and it worked. For this I reported as fixed. But Github actions failed to build the tests when I commited the change.

Will do more tests today and try to provide a minimal project with the problem.

simonjbeaumont commented 4 days ago

@diegotl while surprising, that tallies with what I expect after my investigations. Specifically, this kind of error (where the compiler complains about conflicting symbols) causes a build error BUT it has emitted the module. That means (very surprisingly) if you just run swift build it will then succeed šŸ™ƒ

This is why we're more likely to see projects fail in CI because they always do a clean build.

It would be very helpful if you could confirm that for me. Specifically confirm that:

  1. swift package clean && swift build fails.
  2. swift build again succeeds.

Now, this is not a fix but it will be useful data because I feel we should file a bug report on the Swift compiler for that.

simonjbeaumont commented 4 days ago

@diegotl for a proper fix, I'm proposing #246, which needs review. If you have time, could you also confirm that your project builds fine (from clean) with that PR branch? Would be super helpful.

diegotl commented 4 days ago

@simonjbeaumont Just tried it here, step 1 fails but step 2 also fails!

Haven't tried #246 yet, but for now here's a sample project that fails to build. Will test the proposal later today when I find a little time. Thank you!

sampleproject.zip

MahdiBM commented 4 days ago

I can confirm Penny's problem is solved: https://github.com/vapor/penny-bot/pull/212

Thanks @simonjbeaumont šŸ™‚

diegotl commented 4 days ago

Yes, #246 is good! Thank you @simonjbeaumont!