swift-crypto icon indicating copy to clipboard operation
swift-crypto copied to clipboard

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

Open diegotl opened this issue 1 year ago • 1 comments

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

diegotl avatar Jun 28 '24 06:06 diegotl

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

MahdiBM avatar Jun 28 '24 13:06 MahdiBM

@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 avatar Jul 02 '24 15:07 simonjbeaumont

@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 avatar Jul 02 '24 16:07 simonjbeaumont

@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 avatar Jul 02 '24 16:07 simonjbeaumont

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

simonjbeaumont avatar Jul 02 '24 19:07 simonjbeaumont

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

diegotl avatar Jul 02 '24 22:07 diegotl

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

simonjbeaumont avatar Jul 02 '24 22:07 simonjbeaumont

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.

simonjbeaumont avatar Jul 02 '24 23:07 simonjbeaumont

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.

diegotl avatar Jul 03 '24 06:07 diegotl

@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 avatar Jul 03 '24 06:07 simonjbeaumont

@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.

simonjbeaumont avatar Jul 03 '24 06:07 simonjbeaumont

@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

diegotl avatar Jul 03 '24 08:07 diegotl

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

Thanks @simonjbeaumont 🙂

MahdiBM avatar Jul 03 '24 14:07 MahdiBM

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

diegotl avatar Jul 03 '24 15:07 diegotl