Hello,
I think I found a problem under Windows with the repl code from RInside.
The problem appears if I simply compile the code in
RInside/inst/examples/standard using the Makefile.win there,
after a few hacks to deal with spaces in file names and the direction of
slashes.
The problem appears with the example rinside_interactive0.cpp, but to keep
things simple I've stripped out just the repl code into repl.cpp. It is
attached, along with a Makefile that works under Windows, with g++ from
Rtool42, specifically,
set PATH=c:\Rtools42\x86_64-w64-mingw32.static.posic\bin;%PATH%
When repl.exe is run an extra window pops up, and there are random
terminations, and sometimes a crash, especially if you try to plot
something. The program immediately terminates after plotting.
None of this happens under Linux (Ubuntu), where the program works as
expected.
I tried installing gdb using 'pacman -Sy gdb' (following CRAN docs), and
there were no apparent problems, but some of the DLL's had the wrong
version, and gdb could not be started. (Missing DLL's were msys-ffi-8.dll
and msys-unistring-5.dll.)
I was able to build using Visual Studio, and in that case the app crashes
immediately with a complaint about Rcpp_precious_remove. But here I could
bring up a debugger and step trough code, and sure enough it crashes soon
after the call
GET_CALLABLE("Rcpp_precious_remove"). Stepping into this function leads to
Microsoft code in thread_safe_statics.cpp that implements a critical
section, suggesting
that more than one thread is started.
I wonder if the problem is related to the fact that R is not thread safe?
Or could it be that the preserved objects are bigger under Windows?
I'm working with Rcpp_1.0.9 and RInside_0.2.17, with R-4.2.2.
Thanks,
Dominick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20230117/1e7a46f2/attachment.html>
-------------- next part --------------
// -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8; -*-
//
// Example of a planetary motion solver with interactive console
//
// Copyright (C) 2009 Dirk Eddelbuettel
// Copyright (C) 2010 - 2017 Dirk Eddelbuettel and Romain Francois
// Copyright (C) 2017 Dirk Eddelbuettel, Romain Francois and Åukasz Åaniewski-Wołłk
//
// GPL'ed
#include <RInside.h> // for the embedded R via RInside
int main(int argc, char *argv[]) {
RInside R(argc, argv, false, false, true); // Create an embedded R instance
std::cout << "[ You can finish the with Ctrl+D ]" << std::endl;
R.parseEval("options(prompt = 'R console > ')");
R.parseEval("X11()");
R.repl() ;
R.parseEval("dev.off()");
exit(0);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Makefile
Type: application/octet-stream
Size: 347 bytes
Desc: not available
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20230117/1e7a46f2/attachment.obj>
[Rcpp-devel] Rcpp_precious_remove again (Windows)
4 messages · Dirk Eddelbuettel, Dominick Samperi
Hi Dominick, First reflex: uh-oh as 'Rcpp_precious_remove' created some headaches for some people when mixing Rcpp and packages built with Rcpp but not the current one. We think all this got squared away an Rcpp release or two ago so as a first step please make sure _all_ involved packaes are current with CRAN and rebuilt.
On 17 January 2023 at 21:15, Dominick Samperi wrote:
| I think I found a problem under Windows with the repl code from RInside.
| The problem appears if I simply compile the code in
| RInside/inst/examples/standard using the Makefile.win there,
| after a few hacks to deal with spaces in file names and the direction of
| slashes.
(A small and focused PR would be appreciated if there is some cleanup needed).
| The problem appears with the example rinside_interactive0.cpp, but to keep
| things simple I've stripped out just the repl code into repl.cpp. It is
| attached, along with a Makefile that works under Windows, with g++ from
| Rtool42, specifically,
|
| set PATH=c:\Rtools42\x86_64-w64-mingw32.static.posic\bin;%PATH%
|
| When repl.exe is run an extra window pops up, and there are random
| terminations, and sometimes a crash, especially if you try to plot
| something. The program immediately terminates after plotting.
|
| None of this happens under Linux (Ubuntu), where the program works as
| expected.
Yes it built for me. And runs fine (under Ubuntu 22.10). I don't have Windows
around.
| I tried installing gdb using 'pacman -Sy gdb' (following CRAN docs), and
| there were no apparent problems, but some of the DLL's had the wrong
| version, and gdb could not be started. (Missing DLL's were msys-ffi-8.dll
| and msys-unistring-5.dll.)
I wonder if instead of / in addition to gdb you could instrument your windows
binary to log copiously?
| I was able to build using Visual Studio, and in that case the app crashes
| immediately with a complaint about Rcpp_precious_remove. But here I could
| bring up a debugger and step trough code, and sure enough it crashes soon
| after the call
| GET_CALLABLE("Rcpp_precious_remove"). Stepping into this function leads to
| Microsoft code in thread_safe_statics.cpp that implements a critical
| section, suggesting
| that more than one thread is started.
|
| I wonder if the problem is related to the fact that R is not thread safe?
That would bite Linux as well as Windows.
| Or could it be that the preserved objects are bigger under Windows?
I don't see how because relative to machine memory these objects are
still tiny,
| I'm working with Rcpp_1.0.9 and RInside_0.2.17, with R-4.2.2.
All good. Maybe rebuild RInside under that Rcpp just to be sure.
Cheers, Dirk
|
| Thanks,
| Dominick
| x[DELETED ATTACHMENT repl.cpp, plain text]
| x[DELETED ATTACHMENT Makefile, Untyped binary data]
| _______________________________________________
| Rcpp-devel mailing list
| Rcpp-devel at lists.r-forge.r-project.org
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
1 day later
I narrowed the problem down to the call to R_ReplDLLdo1() in RInside, and I built R-4.3.0 pre-release version for Windows from source to investigate further (online instructions by Tomas Kalibera were very helpful). But the problem does not occur with this version of R! Note that the problem did not occur in some older versions of R either. This version-dependence may be related to the fact that this function and others used by Rcpp/RInside are not part of the supported API for R, so the underlying implementation details for internals like external pointers may change. Dominick
On Tue, Jan 17, 2023 at 9:35 PM Dirk Eddelbuettel <edd at debian.org> wrote:
Hi Dominick,
First reflex: uh-oh as 'Rcpp_precious_remove' created some headaches for
some
people when mixing Rcpp and packages built with Rcpp but not the current
one.
We think all this got squared away an Rcpp release or two ago so as a first
step please make sure _all_ involved packaes are current with CRAN and
rebuilt.
On 17 January 2023 at 21:15, Dominick Samperi wrote:
| I think I found a problem under Windows with the repl code from RInside.
| The problem appears if I simply compile the code in
| RInside/inst/examples/standard using the Makefile.win there,
| after a few hacks to deal with spaces in file names and the direction of
| slashes.
(A small and focused PR would be appreciated if there is some cleanup
needed).
| The problem appears with the example rinside_interactive0.cpp, but to
keep
| things simple I've stripped out just the repl code into repl.cpp. It is
| attached, along with a Makefile that works under Windows, with g++ from
| Rtool42, specifically,
|
| set PATH=c:\Rtools42\x86_64-w64-mingw32.static.posic\bin;%PATH%
|
| When repl.exe is run an extra window pops up, and there are random
| terminations, and sometimes a crash, especially if you try to plot
| something. The program immediately terminates after plotting.
|
| None of this happens under Linux (Ubuntu), where the program works as
| expected.
Yes it built for me. And runs fine (under Ubuntu 22.10). I don't have
Windows
around.
| I tried installing gdb using 'pacman -Sy gdb' (following CRAN docs), and
| there were no apparent problems, but some of the DLL's had the wrong
| version, and gdb could not be started. (Missing DLL's were msys-ffi-8.dll
| and msys-unistring-5.dll.)
I wonder if instead of / in addition to gdb you could instrument your
windows
binary to log copiously?
| I was able to build using Visual Studio, and in that case the app crashes
| immediately with a complaint about Rcpp_precious_remove. But here I could
| bring up a debugger and step trough code, and sure enough it crashes soon
| after the call
| GET_CALLABLE("Rcpp_precious_remove"). Stepping into this function leads
to
| Microsoft code in thread_safe_statics.cpp that implements a critical
| section, suggesting
| that more than one thread is started.
|
| I wonder if the problem is related to the fact that R is not thread safe?
That would bite Linux as well as Windows.
| Or could it be that the preserved objects are bigger under Windows?
I don't see how because relative to machine memory these objects are
still tiny,
| I'm working with Rcpp_1.0.9 and RInside_0.2.17, with R-4.2.2.
All good. Maybe rebuild RInside under that Rcpp just to be sure.
Cheers, Dirk
|
| Thanks,
| Dominick
| x[DELETED ATTACHMENT repl.cpp, plain text]
| x[DELETED ATTACHMENT Makefile, Untyped binary data]
| _______________________________________________
| Rcpp-devel mailing list
| Rcpp-devel at lists.r-forge.r-project.org
| https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel
--
dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org
-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20230119/87a3a9f0/attachment.html>
On 19 January 2023 at 19:41, Dominick Samperi wrote:
| I narrowed the problem down to the call to R_ReplDLLdo1() in RInside, and I | built R-4.3.0 pre-release version for Windows from source to investigate | further (online instructions by Tomas Kalibera were very helpful). Yes Tomas is a master of many tools and deep source of tricks and general help. | But the problem does not occur with this version of R! Note that the problem | did not occur in some older versions of R either. | | This version-dependence may be related to the fact that this function and | others used by Rcpp/RInside are not part of the supported API for R, so the | underlying implementation details for internals like external pointers may | change. Well I probably don't agree here. Because (as per your Subject) 'Rcpp_precious_remove' is in this, as we had a bit of transition to get to more effortlessly growing internal objects, I still suspect (as per my first message in this thread) that you may have had a cross of 'old' and 'new' approaches. A simple consisten recompilation generally fixes that. Per the NEWS.Rd we did the finaly clean up (a reset) in 1.0.9. (We had improved unwind_protect since just after that release.) But by all means, keep digging and look around if you think something is suspicious there. It could well that we do something wrong on Windows, or have another issue somewhere. But I remain quite confident that things are generally in good working order -- these RInside examples have all been working fine more or less unchanged for close to a decade. Cheers, Dirk
dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org