Skip to content

Commit 8d30fd2

Browse files
authored
Merge pull request #1225 from RcppCore/unwindProtect
Enable unwind protection by default
2 parents e1dedab + 1f49ff5 commit 8d30fd2

File tree

9 files changed

+47
-22
lines changed

9 files changed

+47
-22
lines changed

ChangeLog

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
2022-07-23 Iñaki Ucar <[email protected]>
2+
3+
* inst/include/Rcpp/r/headers.h: Unwind protection is enabled by default
4+
unless `RCPP_NO_UNWIND_PROTECT` is defined (`RCPP_USE_UNWIND_PROTECT` is
5+
not checked anymore and has no effect)
6+
* inst/include/Rcpp/vector/Vector.h: Switch evaluation to `Rcpp_eval`
7+
* R/Attributes.R: `[[Rcpp::plugins(unwindProtect)]]` is deprecated
8+
* inst/tinytest/cpp/stack.cpp: Adapted
9+
* inst/tinytest/test_exceptions.R: Adapted
10+
* inst/tinytest/test_interface.R: Adapted
11+
* inst/tinytest/testRcppInterfaceExporter/src/config.h: Removed
12+
113
2022-07-10 Dirk Eddelbuettel <[email protected]>
214

315
* docker/ci-4.1/Dockerfile: Add Dockerfile for 4.1 series

R/Attributes.R

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
# Copyright (C) 2012 - 2021 JJ Allaire, Dirk Eddelbuettel and Romain Francois
2+
# Copyright (C) 2012 - 2022 JJ Allaire, Dirk Eddelbuettel and Romain Francois
33
#
44
# This file is part of Rcpp.
55
#
@@ -562,9 +562,11 @@ compileAttributes <- function(pkgdir = ".", verbose = getOption("verbose")) {
562562
PKG_LIBS="-fopenmp"))
563563
}
564564

565-
.plugins[["unwindProtect"]] <- function() {
566-
list(env = list(PKG_CPPFLAGS = "-DRCPP_USE_UNWIND_PROTECT"))
567-
}
565+
.plugins[["unwindProtect"]] <- function() { # nocov start
566+
warning("unwindProtect is enabled by default and this plugin is deprecated.",
567+
" It will be removed in a future version of Rcpp.")
568+
list()
569+
} # nocov end
568570

569571
# register a plugin
570572
registerPlugin <- function(name, plugin) {

inst/NEWS.Rd

+13
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@
33
\newcommand{\ghpr}{\href{https://github.com/RcppCore/Rcpp/pull/#1}{##1}}
44
\newcommand{\ghit}{\href{https://github.com/RcppCore/Rcpp/issues/#1}{##1}}
55

6+
\section{Changes in Rcpp release version x.x.x (xxxx-xx-xx)}{
7+
\itemize{
8+
\item Changes in Rcpp API:
9+
\itemize{
10+
\item Unwind protection is enabled by default (Iñaki in \ghpr{1225}).
11+
It can be disabled by defining \code{RCPP_NO_UNWIND_PROTECT} before
12+
including \code{Rcpp.h}. \code{RCPP_USE_UNWIND_PROTECT} is not checked
13+
anymore and has no effect. The associated plugin \code{unwindProtect}
14+
is therefore deprecated and will be removed in a future release.
15+
}
16+
}
17+
}
18+
619
\section{Changes in Rcpp hotfix release version 1.0.9 (2022-07-02)}{
720
\itemize{
821
\item Changes in Rcpp API:

inst/include/Rcpp/r/headers.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
# pragma pop_macro("makedev")
9696
#endif
9797

98-
#if (defined(RCPP_USE_UNWIND_PROTECT) && defined(R_VERSION) && R_VERSION >= R_Version(3, 5, 0))
98+
#if (!defined(RCPP_NO_UNWIND_PROTECT) && defined(R_VERSION) && R_VERSION >= R_Version(3, 5, 0))
9999
# define RCPP_USING_UNWIND_PROTECT
100100
#endif
101101

inst/include/Rcpp/vector/Vector.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//
22
// Vector.h: Rcpp R/C++ interface class library -- vectors
33
//
4-
// Copyright (C) 2010 - 2020 Dirk Eddelbuettel and Romain Francois
4+
// Copyright (C) 2010 - 2022 Dirk Eddelbuettel and Romain Francois
55
//
66
// This file is part of Rcpp.
77
//
@@ -1128,11 +1128,11 @@ class Vector :
11281128
public:
11291129

11301130
inline SEXP eval() const {
1131-
return Rcpp_fast_eval( Storage::get__(), R_GlobalEnv ) ;
1131+
return Rcpp_eval( Storage::get__(), R_GlobalEnv ) ;
11321132
}
11331133

11341134
inline SEXP eval(SEXP env) const {
1135-
return Rcpp_fast_eval( Storage::get__(), env );
1135+
return Rcpp_eval( Storage::get__(), env );
11361136
}
11371137

11381138

inst/tinytest/cpp/stack.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// misc.cpp: Rcpp R/C++ interface class library -- misc unit tests
44
//
5-
// Copyright (C) 2013 - 2015 Dirk Eddelbuettel and Romain Francois
5+
// Copyright (C) 2013 - 2022 Dirk Eddelbuettel and Romain Francois
66
//
77
// This file is part of Rcpp.
88
//
@@ -19,7 +19,7 @@
1919
// You should have received a copy of the GNU General Public License
2020
// along with Rcpp. If not, see <http://www.gnu.org/licenses/>.
2121

22-
// [[Rcpp::plugins(unwindProtect,cpp11)]]
22+
// [[Rcpp::plugins(cpp11)]]
2323

2424
#include <Rcpp.h>
2525
using namespace Rcpp;

inst/tinytest/testRcppInterfaceExporter/src/config.h

-1
This file was deleted.

inst/tinytest/test_exceptions.R

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
## Copyright (C) 2010 - 2020 Dirk Eddelbuettel and Romain Francois
2+
## Copyright (C) 2010 - 2022 Dirk Eddelbuettel and Romain Francois
33
##
44
## This file is part of Rcpp.
55
##
@@ -37,7 +37,7 @@ expect_identical(class(condition), c("std::range_error", "C++Error", "error", "c
3737
## C++ stack only available for Rcpp::exceptions
3838
expect_true(is.null(condition$cppstack))
3939

40-
expect_identical(condition$call, quote(takeLog(-1L)))
40+
#expect_identical(condition$call, quote(takeLog(-1L)))
4141

4242

4343
#test.rcppException <- function() {
@@ -58,7 +58,7 @@ expect_true(!is.null(condition$cppstack))
5858

5959
expect_identical(class(condition$cppstack), "Rcpp_stack_trace")
6060

61-
expect_equal(condition$call, quote(takeLogRcpp(-1L)))
61+
#expect_equal(condition$call, quote(takeLogRcpp(-1L)))
6262

6363

6464
#test.rcppStop <- function() {
@@ -75,7 +75,7 @@ expect_true(!is.null(condition$cppstack))
7575

7676
expect_identical(class(condition$cppstack), "Rcpp_stack_trace")
7777

78-
expect_equal(condition$call, quote(takeLogStop(-1L)))
78+
#expect_equal(condition$call, quote(takeLogStop(-1L)))
7979

8080

8181
#test.rcppExceptionLocation <- function() {
@@ -95,7 +95,7 @@ expect_identical(class(condition$cppstack), "Rcpp_stack_trace")
9595
#expect_identical(condition$cppstack$file, "exceptions.cpp")
9696
#expect_identical(condition$cppstack$line, 44L)
9797

98-
expect_equal(condition$call, quote(takeLogRcppLocation(-1L)))
98+
#expect_equal(condition$call, quote(takeLogRcppLocation(-1L)))
9999

100100

101101
#test.rcppExceptionLocation <- function() {
@@ -109,7 +109,7 @@ nested <- tryCatch(f1(-1), error = identity)
109109
## Message the same
110110
expect_identical(normal$message, nested$message)
111111

112-
expect_equal(nested$call, quote(takeLogNested(x)))
112+
#expect_equal(nested$call, quote(takeLogNested(x)))
113113

114114

115115
#test.rcppExceptionNoCall <- function() {

inst/tinytest/test_interface.R

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
## Copyright (C) 2018 - 2019 RStudio
2+
## Copyright (C) 2018 - 2022 RStudio
33
##
44
## This file is part of Rcpp.
55
##
@@ -64,9 +64,8 @@ on.exit(Sys.setenv(R_LIBS = old_libs_envvar), add = TRUE)
6464
sys_sep <- if (.Platform$OS.type == "windows") ";" else ":"
6565
Sys.setenv(R_LIBS = paste(c(lib_path, old_lib_paths), collapse = sys_sep))
6666

67-
cfg <- "#define RCPP_USE_UNWIND_PROTECT"
68-
build_package(exporter_name, lib_path, config = cfg)
69-
build_package(user_name, lib_path, config = cfg)
67+
build_package(exporter_name, lib_path)
68+
build_package(user_name, lib_path)
7069

7170
result <- tools::testInstalledPackage(user_name, lib.loc = lib_path, types = "test")
7271

@@ -82,7 +81,7 @@ expect_equal(result, 0L)
8281
## Now test client package without protected evaluation
8382
unlink(user_name, recursive = TRUE)
8483
unlink(paste0(user_name, "-tests"), recursive = TRUE)
85-
build_package(user_name, lib_path, config = character())
84+
build_package(user_name, lib_path, config = "#define RCPP_NO_UNWIND_PROTECT")
8685

8786
result <- tools::testInstalledPackage(user_name, lib.loc = lib_path, types = "test")
8887

0 commit comments

Comments
 (0)