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

Runtime Error Causes Hard Crash When Performing Inserts With Bad Schema #1825

Closed
Beamed opened this Issue Aug 23, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@Beamed

Beamed commented Aug 23, 2018

Setup

Have a Postgres instance available to use.

Versions

  • Rust: 1.28 Stable
  • Diesel: 1.3.2
  • Database: Postgres 9.6
  • Operating System Windows 10

Feature Flags

  • diesel: postgres, r2d2

Problem Description

When attempting to run an insert, the program fails (crashes without panicking or runtime errors). See below output as an example. An error should definitely be returned by the Result type, rather than perform a hard crash immediately.

What are you trying to accomplish?

Inserting a row into the database and getting meaningful error handling.

What is the expected output?

Error: Unable to perform insert into database(or some message)
Hello world!

What is the actual output?

error: process didn't exit successfully: target\debug\DieselTest.exe (exit code: 3221225477)

Are you seeing any additional errors?

error: process didn't exit successfully: target\debug\DieselTest.exe (exit code: 3221225477)

Steps to reproduce

Run the attached code with the "author" field in SQL set as a BIT instead of a BOOLEAN for a postgres backend.

main.zip

Checklist

  • I have already looked over the issue tracker for similar issues.
  • This issue can be reproduced on Rust's stable channel. (Your issue will be
    closed if this is not the case)
@Beamed

This comment has been minimized.

Beamed commented Aug 23, 2018

This is apparently an issue with the schema of the database; I was using a bit when I should have been using a boolean (too much time in MSSQL land). However, I think the error handling here could be improved. I've updated the title to reflect that. Is there anything I can do to assist with that?

@Beamed Beamed changed the title from Runtime Error Causes Hard Crash When Performing Inserts to Runtime Error Causes Hard Crash When Performing Inserts With Bad Schema Aug 23, 2018

@sgrif

This comment has been minimized.

Member

sgrif commented Aug 31, 2018

I've attempted to reproduce your issue with the steps provided, and was unable to. As written, the code prints Hello, world!. If I add a .unwrap to your insert to view any runtime errors, I receive this error:

"column "author" is of type bit but expression is of type boolean"

A cursory googling shows that the error code you provided is a generic access error on Windows (e.g. their version of a segfault). There is no unsafe code involved in the serialization of booleans, so I suspect this is caused by a misconfiguration in your system, likely in the version of libpq.dll you are linking against.

Since there appears to be no actionable bug in Diesel here, I'm going to close this issue. Feel free to continue to ask questions here, but I can't guarantee we will be able to help with specific configuration issues

@sgrif sgrif closed this Aug 31, 2018

@Beamed

This comment has been minimized.

Beamed commented Aug 31, 2018

Thanks for digging further into the issue; I was unable to find information on the error itself at all.

It looks like you're able to get an appropriate error; was it maybe an issue of the nightly on Aug 22nd?

Agreed it is probably an issue of libpq.dll, especially since I cannot replicate it on Linux.

I'll update my libpq.dll (somehow) and try to replicate with my test program later this weekend and follow up on this issue. Thank you for responding and taking care to ensure the error handling story is good! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment