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

Two ways to fix the Snowflake FFI crash #623

Merged
merged 2 commits into from
Feb 2, 2022

Conversation

mildbyte
Copy link
Contributor

@mildbyte mildbyte commented Feb 1, 2022

Pin cffi to <=1.14.

Versions after that vendor a libffi-9c61262e.so.8.1.0 which would be great except when we are running inside of a PostgreSQL process (which itself, in the case of PG12, uses libffi.so.6). In that case the Python code resolves to the cffi symbols from the system library (rather than the vendored libffi library) and crashes with ABI errors:

$ docker run --rm -it --entrypoint bash splitgraph/engine:development
LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libffi.so.6 python3 -c "from OpenSSL.SSL import _VerifyHelper; _VerifyHelper(lambda cnx, x509, err_no, err_depth, return_code: err_no == 0)"
ffi_prep_closure(): bad user_data (it seems that the version of the libffi library seen at runtime is different from the 'ffi.h' file seen at compile-time)

1.14 comes with libffi-c643fa1a.so.6.0.4 which is compatible with the version inside of the engine (and that PG requires).

There are two commits in this PR that both fix this issue. Not sure which one we should pick:

  • Only pinning in the engine: won't prevent packages that we don't care about running in the engine from upgrading (e.g. cryptography might eventually require cffi >= 1.15). OTOH some other images of ours in the parent repo that are based on PG might accidentally pull in cffi 1.15 and start crashing, unless we make sure to have this manual pin in every image we build.
  • Pinning in Splitgraph's pyproject.toml: vice versa, might hold back other packages from upgrading but we'll be certain we can't accidentally install cffi 1.15 in other images in the parent repo.

Versions after that vendor a libffi-9c61262e.so.8.1.0 which would be
great except when we are running inside of a PostgreSQL process (which itself,
in the case of PG12, uses libffi.so.6). In that case the Python code resolves to
the cffi symbols from the system library (rather than the vendored libffi
library) and crashes with ABI errors:

```
$ docker run --rm -it --entrypoint bash splitgraph/engine:development
LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libffi.so.6 python3 -c "from OpenSSL.SSL import _VerifyHelper; _VerifyHelper(lambda cnx, x509, err_no, err_depth, return_code: err_no == 0)"
ffi_prep_closure(): bad user_data (it seems that the version of the libffi library seen at runtime is different from the 'ffi.h' file seen at compile-time)
```
@mildbyte mildbyte force-pushed the bugfix/snowflake-cffi-abi-fix branch from c5c6e8d to 7a1fcde Compare February 2, 2022 08:43
@mildbyte mildbyte merged commit ada87a2 into master Feb 2, 2022
@mildbyte mildbyte deleted the bugfix/snowflake-cffi-abi-fix branch February 2, 2022 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant