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

segmentation fault in docker containers #38

Closed
zkourouma opened this issue Nov 10, 2021 · 3 comments
Closed

segmentation fault in docker containers #38

zkourouma opened this issue Nov 10, 2021 · 3 comments

Comments

@zkourouma
Copy link

running Ubuntu 18.04.6 LTS in a docker container it looks like upgrading the proc-macro2 from 1.0.30 to 1.0.32 and syn from 1.0.80 to 1.0.81 (from diesel_derives) produces a segmentation fault when calling PQconnectdb

i tried reinstalling postgresql-client-10 since everything seems fine outside of docker and it would've been a dependency issue, but i'm not as familiar with rust's ffi's or debugging seg faults.

can provide more context/info if you need it, but it should be reproducible. i'm running rustc 1.55.0-nightly (a85f584ae 2021-06-16) and the structure of the connection string is postgresql://{username}:{password}@{hostname}:{port}/{database_name}

@weiznich
Copy link
Collaborator

Unfortunately this bug report is not really helpful as it is currently written. Can you provide the following information:

  • A gdb backtrace for the segmentation fault
  • Ideally a reproducible example that someone can take and run to see the issue. As this seems to happen in a docker container you should only need to provide the corresponding code + your Dockerfile + instructions how to run the command inside of the docker container.

@zkourouma
Copy link
Author

here is the gdb backtrace

#0  0x00007f8c93af9f22 in SSL_get_peer_certificate () from /usr/lib/x86_64-linux-gnu/libssl.so.1.1
#1  0x00007f8c94d49ccc in ?? () from /usr/lib/x86_64-linux-gnu/libpq.so.5
#2  0x00007f8c94d31c80 in PQconnectPoll () from /usr/lib/x86_64-linux-gnu/libpq.so.5
#3  0x00007f8c94d32aff in ?? () from /usr/lib/x86_64-linux-gnu/libpq.so.5
#4  0x00007f8c94d35927 in PQconnectdb () from /usr/lib/x86_64-linux-gnu/libpq.so.5
#5  0x0000560cc5c7a75e in diesel::pg::connection::raw::RawConnection::establish (database_url=...) at /home/dev/.cargo/registry/src/github.com-1ecc6299db9ec823/diesel-1.4.8/src/pg/connection/raw.rs:25
(More stack frames follow...)

i ended up "solving" the issue by disabling sslmode in the database url, but i wasn't able to reproduce it with a more stripped down docker container. thanks anyway

@weiznich
Copy link
Collaborator

This sounds like diesel-rs/diesel#813 then. If I remember correctly the issue there was that libpq did not correctly handle concurrent calls to PQconnectdb, which internally calls the openssl init function (which is not thread safe). One workaround here is to depend on the openssl crate and call openssl::init() at the beginning of your main function.

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

No branches or pull requests

2 participants