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

894: Fix error-reporting crash in non-blocking connection. #895

Merged
merged 4 commits into from
Oct 5, 2024

Conversation

jtv
Copy link
Owner

@jtv jtv commented Oct 5, 2024

Fixes: #894

If construction of a non-blocking connection failed for a reason other than an out-of-memory error, then reporting of the error would fail. This happened because the error-reporting code tried to read the error message after it had already cleared the connection pointer. This means reading deallocated memory.

There was an unrelated complication. In maintainer mode (extra-strict compiler options), the binarystring unit test elicits a warning from clang: binarystring is deprecated. Yeah duh. There shouldn't be a warning because that piece of test code (like many others) is bracketed in "ignore deprecation" directives. In just this one case, for just this one compiler, that doesn't seem to do the trick. In the end I just disabled that one test for that one compiler. Hate to do it, but this is deprecated code so it's going away anyway.

Oh, and the build also broke because clang 19 in C++17 and C++20 enables the feature test macro for the assume attribute... but then issues a warning in maintainer mode when you actually use the attribute. Which again in maintainer mode means that the build fails.

Fixes: #894

If construction of a non-blocking `connection` failed for a reason
_other_ than an out-of-memory error, then reporting of the error
would fail.  This happened because the error-reporting code tried to
read the error message _after it had already cleared the connection
pointer._  This means reading deallocated memory.
In clang 19, all of a sudden the compile-time feature check for
`[[assume()]]` support started issuing a warning: it says that
attribute is a "C++23 extension."  And the maintainer-mode build treats
warnings as wrrors, so...  Kaboom.

The problem is that in this mode, clang 19 does define the feature test
macro for this attribute even in C++ 17, but when you actually _use_ the
attribute, clang warns (at least with strict checking options) that it
is not part of C++17 (or C++20, as the case may be).

To get around that, I wrote a more substantial feature check and ran it
at _configure_ time.  This is where my work on systematising the feature
check mechanism really pays off — a few years ago this would have been a
fairly substantial change, with lots of opportunities to do it wrong.
For some reason the line in this unit test where we create a
`std::vector<pqxx::binarystring>` triggers a deprecation warning, even
though the line is bracketed in an "ignore deprecations" block.

Since the whole class is deprecated, it wasn't really worth fixing
properly.  I'll just stop building this test on clang, until the time
comes to drop the whole class and its tests anyway.  Which I hope is
not too far off.
@jtv jtv merged commit 7287495 into master Oct 5, 2024
7 checks passed
@jtv jtv deleted the 894-async-error-handling branch October 5, 2024 20:17
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.

Invalid error message in non blocking pqxx::connection constructor
1 participant