diesel-rs / diesel

A safe, extensible ORM and Query Builder for Rust
https://diesel.rs
Apache License 2.0
12.76k stars 1.07k forks source link

Diesel insert_into crashed! #2132

Closed coderBuffalo closed 4 years ago

coderBuffalo commented 5 years ago

Setup

Versions

stable-x86_64-pc-windows-gnu (default) nightly-x86_64-pc-windows-gnu

Feature Flags

[package] name = "diesel_demo_step_3_pg" version = "0.1.0" authors = ["Sean Griffin sean@seantheprogrammer.com"]

[dependencies] diesel = { version = "1.4.0", features = ["postgres"] } dotenv = "0.10"

Problem Description

I try diesel example of postgres(getting_started_step_3), when i run cargo run --bin write_post, the process crashed, but data been inserted into database.

I change create_post function more simple as below, it still crash.

pub fn create_post(conn: &PgConnection) -> Post {
    use schema::posts;

    let new_post = NewPost { title:"test", body:"test" };

    diesel::insert_into(posts::table)
        .values(&new_post)
        .get_result(conn)
        .expect("Error saving new post")
}
Finished dev [unoptimized + debuginfo] target(s) in 1.08s
     Running `target\debug\write_post.exe`
error: process didn't exit successfully: `target\debug\write_post.exe` (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)
Segmentation fault

What are you trying to accomplish?

hope diesel examples of postgres run success in window 10 64

weiznich commented 5 years ago

Could you provide a debugger backtrace? Without that the bugreport is not really actionable for us.

coderBuffalo commented 5 years ago

Could you provide a debugger backtrace? Without that the bugreport is not really actionable for us.

Thank you for your timely answering, Im new to rust and diesel, after set RUST_BACKTRACE=1 before code, there are no trace!!

asus@LAPTOP-20B8JQLU MINGW64 /d/JOHNSON/work/Test/rust/diesel_example/postgres/getting_started_step_3$ RUST_BACKTRACE=1 cargo run --bin write_post
    Finished dev [unoptimized + debuginfo] target(s) in 0.12s
     Running `target\debug\write_post.exe`
error: process didn't exit successfully: `target\debug\write_post.exe` (exit code: 0xc0000005, STATUS_ACCESS_VIOLATION)Segmentation fault

asus@LAPTOP-20B8JQLU MINGW64 /d/JOHNSON/work/Test/rust/diesel_example/postgres/getting_started_step_3
$ RUST_BACKTRACE=1 target/debug/write_post.exeSegmentation fault

asus@LAPTOP-20B8JQLU MINGW64 /d/JOHNSON/work/Test/rust/diesel_example/postgres/getting_started_step_3
$ RUST_BACKTRACE=1 target/debug/show_posts
Segmentation fault
weiznich commented 5 years ago

You need to execute the binary under a debugger like gdb and capture the stacktrace there after hitting the segfault.

https://ftp.gnu.org/old-gnu/Manuals/gdb/html_node/gdb_42.html

coderBuffalo commented 5 years ago

You need to execute the binary under a debugger like gdb and capture the stacktrace there after hitting the segfault.

https://ftp.gnu.org/old-gnu/Manuals/gdb/html_node/gdb_42.html

Thank you sir, the gdb stacktrace is:

(gdb) run
Starting program: D:\JOHNSON\work\Test\rust\diesel_example\postgres\getting_started_step_3\target\debug\write_post.exe[New Thread 24224.0x5e8c]
[New Thread 24224.0x596c]
[New Thread 24224.0x3e70]
Error while reading shared library symbols for D:\JOHNSON\software\Git\mingw64\bin\ssleay32.dll:
D:\JOHNSON\software\Git\mingw64\bin\ssleay32.dll: error reading symbols
Error while reading shared library symbols for D:\JOHNSON\software\Git\mingw64\bin\libeay32.dll:
D:\JOHNSON\software\Git\mingw64\bin\libeay32.dll: error reading symbols
Error while reading shared library symbols for D:\JOHNSON\software\Git\mingw64\bin\ssleay32.dll:
D:\JOHNSON\software\Git\mingw64\bin\ssleay32.dll: error reading symbols
Error while reading shared library symbols for D:\JOHNSON\software\Git\mingw64\bin\libeay32.dll:
D:\JOHNSON\software\Git\mingw64\bin\libeay32.dll: error reading symbols
Error while reading shared library symbols for D:\JOHNSON\software\Git\mingw64\bin\ssleay32.dll:
D:\JOHNSON\software\Git\mingw64\bin\ssleay32.dll: error reading symbols
Error while reading shared library symbols for D:\JOHNSON\software\Git\mingw64\bin\libeay32.dll:
D:\JOHNSON\software\Git\mingw64\bin\libeay32.dll: error reading symbols
Error while reading shared library symbols for D:\JOHNSON\software\Git\mingw64\bin\ssleay32.dll:
D:\JOHNSON\software\Git\mingw64\bin\ssleay32.dll: error reading symbols
Error while reading shared library symbols for D:\JOHNSON\software\Git\mingw64\bin\libeay32.dll:
D:\JOHNSON\software\Git\mingw64\bin\libeay32.dll: error reading symbols
Error while reading shared library symbols for D:\JOHNSON\software\Git\mingw64\bin\ssleay32.dll:
D:\JOHNSON\software\Git\mingw64\bin\ssleay32.dll: error reading symbols
Error while reading shared library symbols for D:\JOHNSON\software\Git\mingw64\bin\libeay32.dll:
D:\JOHNSON\software\Git\mingw64\bin\libeay32.dll: error reading symbols
Error while reading shared library symbols for D:\JOHNSON\software\Git\mingw64\bin\ssleay32.dll:
D:\JOHNSON\software\Git\mingw64\bin\ssleay32.dll: error reading symbols
Error while reading shared library symbols for D:\JOHNSON\software\Git\mingw64\bin\libeay32.dll:
D:\JOHNSON\software\Git\mingw64\bin\libeay32.dll: error reading symbols
Error while reading shared library symbols for D:\JOHNSON\software\Git\mingw64\bin\ssleay32.dll:
D:\JOHNSON\software\Git\mingw64\bin\ssleay32.dll: error reading symbols
Error while reading shared library symbols for D:\JOHNSON\software\Git\mingw64\bin\libeay32.dll:
D:\JOHNSON\software\Git\mingw64\bin\libeay32.dll: error reading symbols
Error while reading shared library symbols for D:\JOHNSON\software\Git\mingw64\bin\ssleay32.dll:
D:\JOHNSON\software\Git\mingw64\bin\ssleay32.dll: error reading symbols
Error while reading shared library symbols for D:\JOHNSON\software\Git\mingw64\bin\libeay32.dll:
D:\JOHNSON\software\Git\mingw64\bin\libeay32.dll: error reading symbols
Error while reading shared library symbols for D:\JOHNSON\software\Git\mingw64\bin\ssleay32.dll:
D:\JOHNSON\software\Git\mingw64\bin\ssleay32.dll: error reading symbols
Error while reading shared library symbols for D:\JOHNSON\software\Git\mingw64\bin\libeay32.dll:
D:\JOHNSON\software\Git\mingw64\bin\libeay32.dll: error reading symbols
[New Thread 24224.0x62bc]

Thread 1 received signal SIGSEGV, Segmentation fault.
0x000000008000f980 in ?? ()
(gdb) run
Starting program: D:\JOHNSON\work\Test\rust\diesel_example\postgres\getting_started_step_3\target\debug\write_post.exe
[New Thread 20680.0x5230]
[New Thread 20680.0x60bc]
[New Thread 20680.0x4780]
[Thread 20680.0x592c exited with code 3221225781]
[Thread 20680.0x5230 exited with code 3221225781]
[Thread 20680.0x4780 exited with code 3221225781]
During startup program exited with code 0xc0000135.
weiznich commented 5 years ago

That stacktrace looks like you are missing some dependencies. Please double check that there is a compatible openssl version in place.

weiznich commented 4 years ago

Closed as cannot reproduce