Skip to content
Prev 10701 / 10988 Next

[Rcpp-devel] R Session Sometimes Aborts

I ran your example under valgrind on Linux (Ubuntu 20.04) and valgrind
found some memory misuse:

$ R --quiet --no-save --debugger=valgrind
--debugger-args="--track-origins=yes"
==1533== Memcheck, a memory error detector
==1533== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==1533== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==1533== Command: /home/bill/R-devel/R-build/bin/exec/R --quiet --no-save
==1533==
terra version 1.5.2
Loading required package: sp
prob", shift=c(0,1))
prob", shift=c(0,1)) #Often leads to Rsession Aborted
==1533== Invalid read of size 4
==1533==    at 0x1C1ADA01: C_make_glcm(Rcpp::Matrix<13,
Rcpp::PreserveStorage>, int, Rcpp::Vector<13, Rcpp::PreserveStorage>,
Rcpp::String) (glcm_cpp_functions.cpp:73)
==1533==    by 0x1C1B2237: C_glcm_textures_helper2(Rcpp::Vector<13,
Rcpp::PreserveStorage>, Rcpp::Vector<13, Rcpp::PreserveStorage>, int,
Rcpp::Vector<13, Rcpp::PreserveStorage>, Rcpp::String, unsigned long,
unsigned long) (glcm_cpp_functions.cpp:218)
==1533==    by 0x1C1A098D: _GLCMTextures_C_glcm_textures_helper2
(RcppExports.cpp:94)
==1533==    by 0x1F6B01: R_doDotCall (dotcode.c:622)
==1533==    by 0x2637C9: bcEval (eval.c:7695)
==1533==    by 0x240653: Rf_eval (eval.c:748)
==1533==    by 0x243223: R_execClosure (eval.c:1918)
==1533==    by 0x242EFD: Rf_applyClosure (eval.c:1844)
==1533==    by 0x240E06: Rf_eval (eval.c:871)
==1533==    by 0x246CD6: do_set (eval.c:2990)
==1533==    by 0x240A8C: Rf_eval (eval.c:823)
==1533==    by 0x2457DA: do_begin (eval.c:2538)
==1533==  Address 0xa59c0c4 is 28 bytes before a block of size 64 in arena
"client"
==1533==
==1533== Invalid write of size 4
==1533==    at 0x1C1ADA44: C_make_glcm(Rcpp::Matrix<13,
Rcpp::PreserveStorage>, int, Rcpp::Vector<13, Rcpp::PreserveStorage>,
Rcpp::String) (glcm_cpp_functions.cpp:73)
==1533==    by 0x1C1B2237: C_glcm_textures_helper2(Rcpp::Vector<13,
Rcpp::PreserveStorage>, Rcpp::Vector<13, Rcpp::PreserveStorage>, int,
Rcpp::Vector<13, Rcpp::PreserveStorage>, Rcpp::String, unsigned long,
unsigned long) (glcm_cpp_functions.cpp:218)
==1533==    by 0x1C1A098D: _GLCMTextures_C_glcm_textures_helper2
(RcppExports.cpp:94)
==1533==    by 0x1F6B01: R_doDotCall (dotcode.c:622)
==1533==    by 0x2637C9: bcEval (eval.c:7695)
==1533==    by 0x240653: Rf_eval (eval.c:748)
==1533==    by 0x243223: R_execClosure (eval.c:1918)
==1533==    by 0x242EFD: Rf_applyClosure (eval.c:1844)
==1533==    by 0x240E06: Rf_eval (eval.c:871)
==1533==    by 0x246CD6: do_set (eval.c:2990)
==1533==    by 0x240A8C: Rf_eval (eval.c:823)
==1533==    by 0x2457DA: do_begin (eval.c:2538)
==1533==  Address 0xa59c0c4 is 28 bytes before a block of size 64 in arena
"client"
==1533==
--1533-- VALGRIND INTERNAL ERROR: Valgrind received a signal 11 (SIGSEGV) -
exiting
--1533-- si_code=1;  Faulting address: 0x10A59C138;  sp: 0x10090e2e20

valgrind: the 'impossible' happened:
   Killed by fatal signal

host stacktrace:
==1533==    at 0x580505C4: ??? (in
/usr/lib/x86_64-linux-gnu/valgrind/memcheck-amd64-linux)
==1533==    by 0x58004EBB: ??? (in
/usr/lib/x86_64-linux-gnu/valgrind/memcheck-amd64-linux)
==1533==    by 0x58005DA7: ??? (in
/usr/lib/x86_64-linux-gnu/valgrind/memcheck-amd64-linux)
==1533==    by 0x580A7204: ??? (in
/usr/lib/x86_64-linux-gnu/valgrind/memcheck-amd64-linux)
==1533==    by 0x580F5FD4: ??? (in
/usr/lib/x86_64-linux-gnu/valgrind/memcheck-amd64-linux)

sched status:
  running_tid=1

Thread 1: status = VgTs_Runnable (lwpid 1533)
==1533==    at 0x483BE63: operator new(unsigned long) (in
/usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==1533==    by 0x6E92D3C: void std::__cxx11::basic_string<char,
std::char_traits<char>, std::allocator<char> >::_M_construct<char
const*>(char const*, char const*, std::forward_iterator_tag) (in
/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28)
==1533==    by 0x1C1B2377: C_glcm_textures_helper2(Rcpp::Vector<13,
Rcpp::PreserveStorage>, Rcpp::Vector<13, Rcpp::PreserveStorage>, int,
Rcpp::Vector<13, Rcpp::PreserveStorage>, Rcpp::String, unsigned long,
unsigned long) (glcm_cpp_functions.cpp:221)
==1533==    by 0x1C1A098D: _GLCMTextures_C_glcm_textures_helper2
(RcppExports.cpp:94)
==1533==    by 0x1F6B01: R_doDotCall (dotcode.c:622)
==1533==    by 0x2637C9: bcEval (eval.c:7695)
==1533==    by 0x240653: Rf_eval (eval.c:748)
==1533==    by 0x243223: R_execClosure (eval.c:1918)
==1533==    by 0x242EFD: Rf_applyClosure (eval.c:1844)
==1533==    by 0x240E06: Rf_eval (eval.c:871)
==1533==    by 0x246CD6: do_set (eval.c:2990)
==1533==    by 0x240A8C: Rf_eval (eval.c:823)
==1533==    by 0x2457DA: do_begin (eval.c:2538)
==1533==    by 0x240A8C: Rf_eval (eval.c:823)
==1533==    by 0x244FC9: do_for (eval.c:2420)
==1533==    by 0x240A8C: Rf_eval (eval.c:823)
==1533==    by 0x2457DA: do_begin (eval.c:2538)
==1533==    by 0x240A8C: Rf_eval (eval.c:823)
==1533==    by 0x244FC9: do_for (eval.c:2420)
==1533==    by 0x240A8C: Rf_eval (eval.c:823)
==1533==    by 0x2457DA: do_begin (eval.c:2538)
==1533==    by 0x240A8C: Rf_eval (eval.c:823)
==1533==    by 0x243223: R_execClosure (eval.c:1918)
==1533==    by 0x242EFD: Rf_applyClosure (eval.c:1844)
==1533==    by 0x253F32: bcEval (eval.c:7107)
==1533==    by 0x240653: Rf_eval (eval.c:748)
==1533==    by 0x243223: R_execClosure (eval.c:1918)
==1533==    by 0x243D9C: R_execMethod (eval.c:2094)
==1533==    by 0x8800187: R_dispatchGeneric (methods_list_dispatch.c:1145)
==1533==    by 0x2B15F4: do_standardGeneric (objects.c:1285)
==1533==    by 0x253DB3: bcEval (eval.c:7096)
==1533==    by 0x240653: Rf_eval (eval.c:748)
==1533==    by 0x243223: R_execClosure (eval.c:1918)
==1533==    by 0x242EFD: Rf_applyClosure (eval.c:1844)
==1533==    by 0x253F32: bcEval (eval.c:7107)
==1533==    by 0x240653: Rf_eval (eval.c:748)
==1533==    by 0x243223: R_execClosure (eval.c:1918)
==1533==    by 0x242EFD: Rf_applyClosure (eval.c:1844)
==1533==    by 0x240E06: Rf_eval (eval.c:871)
==1533==    by 0x246CD6: do_set (eval.c:2990)
==1533==    by 0x240A8C: Rf_eval (eval.c:823)
==1533==    by 0x28EF5E: Rf_ReplIteration (main.c:264)
==1533==    by 0x28F157: R_ReplConsole (main.c:316)
==1533==    by 0x290BC0: run_Rmainloop (main.c:1130)
==1533==    by 0x290BDA: Rf_mainloop (main.c:1137)
==1533==    by 0x16F74B: main (Rmain.c:29)
client stack range: [0x1FFEED3000 0x1FFF000FFF] client SP: 0x1FFEFF35F0
valgrind stack range: [0x1008FE3000 0x10090E2FFF] top usage: 12336 of
1048576


Note: see also the FAQ in the source distribution.
It contains workarounds to several common problems.
In particular, if Valgrind aborted or crashed after
identifying problems in your program, there's a good chance
that fixing those problems will prevent Valgrind aborting or
crashing, especially if it happened in m_mallocfree.c.

If that doesn't help, please report this bug to: www.valgrind.org

In the bug report, send all the above text, the valgrind
version, and what OS and version you are using.  Thanks.
On Mon, Dec 13, 2021 at 8:15 AM Alexander Ilich <ailich at mail.usf.edu> wrote:

            
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20211213/268528d8/attachment-0001.html>