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

Compilation Error: *const i8 cannot be sent between threads safely #18

Closed
scull7 opened this issue Nov 20, 2019 · 7 comments
Closed

Compilation Error: *const i8 cannot be sent between threads safely #18

scull7 opened this issue Nov 20, 2019 · 7 comments

Comments

@scull7
Copy link
Contributor

scull7 commented Nov 20, 2019

I'm getting a compilation failure when pulling in oracle. I've tried using the master branch:

oracle = { git = "https://github.com/kubo/rust-oracle.git", features = ["chrono"] }

And version 0.3.1:

oracle = { version = "0.3.1", features = ["chrono"] }

rustc version:

stable-x86_64-apple-darwin unchanged - rustc 1.39.0 (4560ea788 2019-11-04)
error[E0277]: `*const i8` cannot be sent between threads safely
   --> /Users/nathansculli/.cargo/git/checkouts/rust-oracle-858dd8ce065f6a17/2e61902/src/lib.rs:411:1
    |
411 | / lazy_static! {
412 | |     static ref DPI_CONTEXT: ContextResult = {
413 | |         let mut ctxt = Context {
414 | |             context: ptr::null_mut(),
...   |
449 | |     };
450 | | }
    | |_^ `*const i8` cannot be sent between threads safely
    |
    = help: within `ContextResult`, the trait `std::marker::Send` is not implemented for `*const i8`
    = note: required because it appears within the type `binding::dpiErrorInfo`
    = note: required because it appears within the type `ContextResult`
    = note: required because of the requirements on the impl of `std::marker::Sync` for `spin::once::Once<ContextResult>`
    = note: required because it appears within the type `lazy_static::lazy::Lazy<ContextResult>`
    = note: shared static variables must have a type that implements `Sync`
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.
error: could not compile `oracle`.
@scull7
Copy link
Contributor Author

scull7 commented Nov 20, 2019

I've also tried to compile without enabling the "chrono" feature, I receive the same error.

@mexus
Copy link

mexus commented Nov 21, 2019

Can't reproduce on rustc 1.39.0 on linux; could it be some mac-related issue?

@kubo
Copy link
Owner

kubo commented Nov 21, 2019

@scull7
I could not reproduced the issue on Linux and macOS.

$ rustup toolchain list
stable-x86_64-apple-darwin (default)
$ rustc --version
rustc 1.39.0 (4560ea788 2019-11-04)
$ cargo new oracle-app
     Created binary (application) `oracle-app` package
$ cd oracle-app/
$ echo 'oracle = { git = "https://github.com/kubo/rust-oracle.git", features = ["chrono"] }' >> Cargo.toml 
$ cargo build
    Updating git repository `https://github.com/kubo/rust-oracle.git`
    Updating crates.io index
  Downloaded chrono v0.4.9
  Downloaded autocfg v0.1.7
  Downloaded num-traits v0.2.9
   Compiling proc-macro2 v1.0.6
   Compiling autocfg v0.1.7
   Compiling unicode-xid v0.2.0
   Compiling syn v1.0.8
   Compiling libc v0.2.65
   Compiling cc v1.0.47
   Compiling lazy_static v1.4.0
   Compiling try_from v0.2.2
   Compiling num-traits v0.2.9
   Compiling num-integer v0.1.41
   Compiling quote v1.0.2
   Compiling time v0.1.42
   Compiling oracle v0.3.1 (https://github.com/kubo/rust-oracle.git#2e619029)
   Compiling chrono v0.4.9
   Compiling proc-macro-hack v0.5.11
   Compiling paste-impl v0.1.6
   Compiling paste v0.1.6
   Compiling oracle-app v0.1.0 (/Users/kubo/oracle-app)
    Finished dev [unoptimized + debuginfo] target(s) in 46.33s

Could you paste the contents of Cargo.lock to gist and post the link? I want to know the exact depending crate versions on your environment.

@scull7
Copy link
Contributor Author

scull7 commented Nov 21, 2019

Here's my Cargo.lock file: https://gist.github.com/scull7/41be1d15360258d351c5658cef90247a

@scull7
Copy link
Contributor Author

scull7 commented Nov 24, 2019

Is anyone able to shed some light on this? Still stuck.

@kubo
Copy link
Owner

kubo commented Nov 24, 2019

I found that the error appeared when oracle is used with tracing-core >= 0.1.4 (after this commit). I don't know why.

I'll add unsafe impl Send for ContextResult {} in src/lib.rs for workaround.

@scull7
Copy link
Contributor Author

scull7 commented Nov 24, 2019

Thank you 🙏

scull7 added a commit to scull7/rust-oracle that referenced this issue Nov 24, 2019
kubo added a commit that referenced this issue Nov 24, 2019
ContextResult is read-only after it is initialized by lasy_static.
So it can implement Send.
(fix #18)
kubo pushed a commit that referenced this issue Nov 24, 2019
@kubo kubo closed this as completed in 87df5b8 Nov 24, 2019
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

3 participants