Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tink Python 1.9 Can't Get Mutex Lock on Import #25

Open
tdipadova3rd opened this issue Dec 11, 2023 · 7 comments
Open

Tink Python 1.9 Can't Get Mutex Lock on Import #25

tdipadova3rd opened this issue Dec 11, 2023 · 7 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@tdipadova3rd
Copy link

Help us help you

We'd like to know more about
your Tink deployment.

Describe the bug:

When importing Tink (with GCPSM Extension) for use in a FastAPI service using Uvicorn, we consistently see the error libc++abi: terminating due to uncaught exception of type std::__1::system_error: mutex lock failed: Invalid argument, and the entire python process will crash. Pinning Tink to 1.8 solves this for us.
We also have a Dramatiq service that throws the same error on Tink import. This happens on both Mac (M1/M2) and Linux (Ubuntu) machines in the Cloud.

What was the expected behavior?

We should be able to import Tink for use in Dramatiq and FastAPI services.

How can we reproduce the bug?

This can be triggered by importing certain other packages, including but not limited to, snowflake-connector-python.

Do you have any debugging information?

I have attached a crash log.
crash-report.txt

What version of Tink are you using?

Tink 1.9.0. Tink 1.8.0 is not affected by this issue.

Can you tell us more about your development environment?

Python 3.11, Virtual Environment managed by Poetry. Mac OS 13 (M2), Mac OS 14 (M1), Ubuntu.

Is there anything else you'd like to add?

Provide any additional context about the problem.

@morambro
Copy link
Contributor

Hi @tdipadova3rd, could you please provide a minimum code example to reproduce this? Is it sufficient to have import dramatiq and import tink in the same script and e.g., use tink within a dramatique task?

@morambro morambro self-assigned this Dec 11, 2023
@morambro morambro added bug Something isn't working question Further information is requested labels Dec 11, 2023
@tdipadova3rd
Copy link
Author

Hi @morambro, thanks for the quick response!

I am able to repro with just two lines of code (test.py):

import snowflake.connector
import tink

via poetry run python test.py

The error occurs on import tink, killing the process.

Note: This also happens with some other packages, the snowflake.connector is just the most recent example.

I've attached a poetry export as well to give you a sense of the other packages in the environment.
repro-requirements.txt

@morambro
Copy link
Contributor

morambro commented Dec 12, 2023

Thanks! I tried to reproduce the issue without success. My attempt on a Ubuntu 2004 VM (e2-standard-4):

# Python 3.11.7.
poetry new tink-py-issue-25
cd tink-py-issue-25
poetry add tink==1.9.0
poetry add snowflake-connector-python  # installs snowflake-connector-python==3.6.0 
cat <<EOF > test.py
import snowflake.connector
import tink
EOF
poetry run python test.py

The above runs fine.

UPDATE: Works fine also on a t2a-standard-4 (ARM) Ubuntu 2310 VM

@tdipadova3rd
Copy link
Author

Hmmm perhaps there's another library in our environment that causes the tink import to fail? It's curious that I can trigger the issue from those two lines of code with the linked Python environment from two separate machines (Mac M1 and Mac M2).

@mallport
Copy link

mallport commented Mar 3, 2024

Hey! I also have the same issue, and after a bit of dependency-mining, I've narrowed the source (in our case) down to the case where both pyarrow and tink>1.9.0 is imported. The error can be reproduced as follows, following the same structure as @morambro.

# Python 3.11.6.
poetry new tink-py-issue-25
cd tink-py-issue-25
poetry add tink==1.9.0
poetry add pyarrow  # installs pyarrow==15.0.0
cat <<EOF > test.py
import pyarrow
import tink
EOF
poetry run python test.py

Ran on a M2 Mac

@mallport
Copy link

mallport commented Mar 4, 2024

I see this issue is also brought up in the Arrow-library. Link:
apache/arrow#40088

@frankpf
Copy link

frankpf commented Aug 7, 2024

Hi @morambro! I am also seeing this on a M1 Mac with apache_beam. To reproduce, you can use the same commands from the message above, but replace pyarrow with apache_beam.

Depending on the order of the imports, I get a slightly different error message:

Screenshot 2024-08-07 at 17 46 51 Screenshot 2024-08-07 at 17 48 44

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants