[MONGOCRYPT-17] Unable to statically link to libmongocrypt due to missing libbson symbols Created: 11/Jun/19  Updated: 28/Oct/23  Resolved: 27/Jun/19

Status: Closed
Project: Libmongocrypt
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Matt Broadstone Assignee: Roberto Sanchez
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Epic Link: Build libmongocrypt library

 Description   

When statically linking to libmongocrypt for the node binding, we run into the following segfaults during test execution:

[mbroadst@gorgor node-mongodb-crypt (master ✗)]$ npm test
 
> mongodb-crypt@0.0.1 test /Users/mbroadst/Development/mongo/node-mongodb-crypt
> mocha test
 
 
 
  AutoEncrypter
    state machine
dyld: lazy symbol binding failed: Symbol not found: _bson_malloc0
  Referenced from: /Users/mbroadst/Development/mongo/node-mongodb-crypt/build/Release/mongocrypt.node
  Expected in: flat namespace
 
dyld: Symbol not found: _bson_malloc0
  Referenced from: /Users/mbroadst/Development/mongo/node-mongodb-crypt/build/Release/mongocrypt.node
  Expected in: flat namespace

it seems like libbson's symbols are missing.



 Comments   
Comment by Githook User [ 27/Jun/19 ]

Author:

{'name': 'Roberto C. Sánchez', 'username': 'rcsanchez97', 'email': 'roberto@connexer.com'}

Message: CDRIVER-3187 ship libbson static lib in evergreen tarball on windows
Branch: master
https://github.com/mongodb/libmongocrypt/commit/39a8574fad67f316adbd9c8662695e526461d91a

Comment by Githook User [ 27/Jun/19 ]

Author:

{'name': 'Roberto C. Sánchez', 'username': 'rcsanchez97', 'email': 'roberto@connexer.com'}

Message: CDRIVER-3187 ship libbson static lib in evergreen tarball
Branch: master
https://github.com/mongodb/libmongocrypt/commit/2c8698a7b895e3a5433bd535995aa7c990d949b6

Comment by Matt Broadstone [ 25/Jun/19 ]

Yes, I think that would resolve the issue.

Comment by Kevin Albertson [ 20/Jun/19 ]

matt.broadstone just to confirm, it is sufficient to copy libbson-static-1.0.a alongside libmongocrypt-static.a, right?

Comment by Roberto Sanchez [ 17/Jun/19 ]

matt.broadstone, I was able to reproduce the error when the libraries included only libmongocrypt-static.a. However, when I added libbson-static-1.0.a, everything worked. Is the inclusion of libbson-static-1.0.a problematic in some way? The only thing that springs to mind is that it would need to made available on the system. Since the Node build already needs to download the libmongocrypt artifacts, the libmongocrypt build could be modified to copy libbson-static-1.0.a in alongside libmongocrypt-static.a, which would guarantee the availability of libbson-static-1.0.a in a known good location for every build. Would that solve the problem in an acceptable way?

Comment by Kevin Albertson [ 14/Jun/19 ]

matt.broadstone to clarify, do you want libmongocrypt-static.a to include the definitions of libbson symbols, or just to have libbson-static.a easily accessible, so both libmongocrypt-static.a and libbson-static.a can be specified in binding.gyp?

Generated at Thu Feb 08 09:07:45 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.