FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix: Copy strings before calling `Rf_warningcall()` to avoid weird unwind behavior by krlmlr · Pull Request #422 · r-lib/cpp11 · GitHub

/ cpp11 Public

fix: Copy strings before calling Rf_warningcall() to avoid weird unwind behavior - #422

Closed
krlmlr wants to merge 1 commit into
mainfrom
b-warning-copy
Closed

krlmlr wants to merge 1 commit into
mainfrom
b-warning-copy

Conversation

krlmlr commented Dec 7, 2024 •
edited
Loading

Copy link
Copy Markdown
Member

From duckdb, see #401.

I'd need to dig up the motivation here, but I'm pretty sure this made a difference at some point.

krlmlr requested a review from DavisVaughan December 7, 2024 19:46
krlmlr added a commit to duckdb/duckdb-r that referenced this pull request Dec 7, 2024
r-lib/cpp11#422

This reverts commit 1e181e5e5c2cf0a21906b49dafe80364c8ca3f2b.
krlmlr added a commit to duckdb/duckdb-r that referenced this pull request Dec 7, 2024
* Revert "ifndef"

This reverts commit 9afb676.

* Revert "Reapply 782630b minus the whitespace changes"

This reverts commit f05d56c.

* Reapply "Revert a011d42"

This reverts commit fe615c4.

* Reapply "Revert fb18a2d"

This reverts commit 6f4979d.

* Vendor cpp11 0.5.1

* Add `prot` argument to `external_pointer()` constructor

r-lib/cpp11#420

This reverts commit abcae40e2aff8b1664098294959b8df743605737.

* END_CPP11_EX()

r-lib/cpp11#421

* Protection

r-lib/cpp11#422

This reverts commit 1e181e5e5c2cf0a21906b49dafe80364c8ca3f2b.

* External pointer premature release

r-lib/cpp11#423

This reverts commit 1b698e533ea7c7003cb610a5f5f7e5a47966c59d.
krlmlr added a commit to duckdb/duckdb-r that referenced this pull request Dec 8, 2024
* Revert "ifndef"

This reverts commit 9afb676.

* Revert "Reapply 782630b minus the whitespace changes"

This reverts commit f05d56c.

* Reapply "Revert a011d42"

This reverts commit fe615c4.

* Reapply "Revert fb18a2d"

This reverts commit 6f4979d.

* Vendor cpp11 0.5.1

* Add `prot` argument to `external_pointer()` constructor

r-lib/cpp11#420

This reverts commit abcae40e2aff8b1664098294959b8df743605737.

* END_CPP11_EX()

r-lib/cpp11#421

* Protection

r-lib/cpp11#422

This reverts commit 1e181e5e5c2cf0a21906b49dafe80364c8ca3f2b.

* External pointer premature release

r-lib/cpp11#423

This reverts commit 1b698e533ea7c7003cb610a5f5f7e5a47966c59d.
krlmlr added a commit to duckdb/duckdb-r that referenced this pull request Dec 8, 2024
* Revert "ifndef"

This reverts commit 9afb676.

* Revert "Reapply 782630b minus the whitespace changes"

This reverts commit f05d56c.

* Reapply "Revert a011d42"

This reverts commit fe615c4.

* Reapply "Revert fb18a2d"

This reverts commit 6f4979d.

* Vendor cpp11 0.5.1

* Add `prot` argument to `external_pointer()` constructor

r-lib/cpp11#420

This reverts commit abcae40e2aff8b1664098294959b8df743605737.

* END_CPP11_EX()

r-lib/cpp11#421

* Protection

r-lib/cpp11#422

This reverts commit 1e181e5e5c2cf0a21906b49dafe80364c8ca3f2b.

* External pointer premature release

r-lib/cpp11#423

This reverts commit 1b698e533ea7c7003cb610a5f5f7e5a47966c59d.
krlmlr added a commit to duckdb/duckdb-r that referenced this pull request Mar 9, 2025
r-lib/cpp11#422

This reverts commit 1e181e5e5c2cf0a21906b49dafe80364c8ca3f2b.
krlmlr added a commit to duckdb/duckdb-r that referenced this pull request Mar 9, 2025
* Revert "External pointer premature release"

This reverts commit d7886e3.

* Revert "Protection"

This reverts commit 4f4a3a8.

* Revert "END_CPP11_EX()"

This reverts commit aa3225d.

* Revert "Add `prot` argument to `external_pointer()` constructor"

This reverts commit d045ccf.

* Header

* Substance

* Add `prot` argument to `external_pointer()` constructor

r-lib/cpp11#420

This reverts commit abcae40e2aff8b1664098294959b8df743605737.

* END_CPP11_EX()

r-lib/cpp11#421

* Protection

r-lib/cpp11#422

This reverts commit 1e181e5e5c2cf0a21906b49dafe80364c8ca3f2b.

* External pointer premature release

r-lib/cpp11#423

This reverts commit 1b698e533ea7c7003cb610a5f5f7e5a47966c59d.
krlmlr added a commit to krlmlr/cpp11 that referenced this pull request Sep 12, 2026
Upstream fixed the root cause in r-lib#493,
so this patch has nothing left to do
and the conflict resolves to removing the feature.

This branch worked around r-lib#295 --
`cpp11::warning(const char*)` crashed where
`cpp11::warning(const std::string&)` did not --
by deleting the `const char*` overloads
and taking the format argument by value,
routing every caller through the path that did not crash.

r-lib#493 removes the cause rather than the symptom:
`Rf_errorcall()` and `Rf_warningcall()` share a function type,
so `stop()` and `warning()` collapsed into one
`detail::closure` / `detail::apply()` instantiation,
and the `[[noreturn]]` flavour could render `warning()`'s
return path unreachable.
Upstream now tags the templates with `detail::return_tag`
and `detail::no_return_tag`,
and ships a regression test that calls
`cpp11::warning("%s", "warning")` -- the `const char*` overload --
from a translation unit separate from one calling `cpp11::stop()`,
which is exactly the r-lib#295 scenario.
Its NEWS bullet cites r-lib#295 by number.

Keeping the workaround would now cost something for nothing:
it removes public `const char*` overloads from the header
and constructs a `std::string` on every warning call.

The upstream pull request carrying this patch,
r-lib#422, was closed unmerged on the day r-lib#493 landed.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K8MneV8KqHYUuC8fWV3X5Q
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

1 participant


Back | FazBrowse Home | New Git URL