Need help to understand Valgrind diagnostic

Hello,

I've submitted a new version of my package 'gfilmm' and the CRAN checks on Solaris (only Solaris) detect a caught segfault ("memory not mapped"). This package uses 'Rcpp'.

I've run some code with Valgrind but I don't know what to conclude from the output:

 ==25756== Invalid read of size 16
==25756==    at 0x5591758: __wcsnlen_sse4_1 (strlen.S:117)
==25756==    by 0x557ECA1: wcsrtombs (wcsrtombs.c:104)
==25756==    by 0x5504C40: wcstombs (wcstombs.c:34)
==25756==    by 0x4EF2F62: ??? (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F6BED0: ??? (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F78C7F: Rf_eval (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F7AADE: ??? (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F7B822: Rf_applyClosure (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F6F821: ??? (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F78C7F: Rf_eval (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F7AADE: ??? (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F7B822: Rf_applyClosure (in /usr/lib/R/lib/libR.so)
==25756==  Address 0x228bf5e0 is 8 bytes after a block of size 8 alloc'd
==25756==    at 0x4C33B25: calloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==25756==    by 0x4FAD8A0: R_chk_calloc (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4EF2EF3: ??? (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F6BED0: ??? (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F78C7F: Rf_eval (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F7AADE: ??? (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F7B822: Rf_applyClosure (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F6F821: ??? (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F78C7F: Rf_eval (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F7AADE: ??? (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F7B822: Rf_applyClosure (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F78E49: Rf_eval (in /usr/lib/R/lib/libR.so)
==25756== 
==25756== Invalid read of size 16
==25756==    at 0x559175D: __wcsnlen_sse4_1 (strlen.S:117)
==25756==    by 0x557ECA1: wcsrtombs (wcsrtombs.c:104)
==25756==    by 0x5504C40: wcstombs (wcstombs.c:34)
==25756==    by 0x4EF2F62: ??? (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F6BED0: ??? (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F78C7F: Rf_eval (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F7AADE: ??? (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F7B822: Rf_applyClosure (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F6F821: ??? (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F78C7F: Rf_eval (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F7AADE: ??? (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F7B822: Rf_applyClosure (in /usr/lib/R/lib/libR.so)
==25756==  Address 0x228bf5f0 is 16 bytes after a block of size 16 in arena "client"
==25756== 
==25756== Invalid read of size 16
==25756==    at 0x5591762: __wcsnlen_sse4_1 (strlen.S:117)
==25756==    by 0x557ECA1: wcsrtombs (wcsrtombs.c:104)
==25756==    by 0x5504C40: wcstombs (wcstombs.c:34)
==25756==    by 0x4EF2F62: ??? (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F6BED0: ??? (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F78C7F: Rf_eval (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F7AADE: ??? (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F7B822: Rf_applyClosure (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F6F821: ??? (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F78C7F: Rf_eval (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F7AADE: ??? (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F7B822: Rf_applyClosure (in /usr/lib/R/lib/libR.so)
==25756==  Address 0x228bf600 is 32 bytes before an unallocated block of size 29,248 in arena "client"
==25756== 
==25756== Conditional jump or move depends on uninitialised value(s)
==25756==    at 0x5591831: __wcsnlen_sse4_1 (strlen.S:161)
==25756==    by 0x557ECA1: wcsrtombs (wcsrtombs.c:104)
==25756==    by 0x5504C40: wcstombs (wcstombs.c:34)
==25756==    by 0x4EF2F62: ??? (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F6BED0: ??? (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F78C7F: Rf_eval (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F7AADE: ??? (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F7B822: Rf_applyClosure (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F6F821: ??? (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F78C7F: Rf_eval (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F7AADE: ??? (in /usr/lib/R/lib/libR.so)
==25756==    by 0x4F7B822: Rf_applyClosure (in /usr/lib/R/lib/libR.so)
==25756== 

What could be the reason of "Invalid read of size 16"? Do you have any clue?

Also, would you have any clue about why this error occurs on Solaris only?

The C++ code is available on Github but it is >1000 lines and a bit complex.

My best guess, based on lineage of Solaris, but it’s been 25 years since I’ve had any experience with that dialect.

But what does that mean please?

It means that valgrind was compiled against vgpreload_memcheck-amd64-linux.so, which suggests to me that details of memory addressing are platform-specific, which is consistent with the first read size of 8 succeeding, but the subsequent size 16s do not.

But then, what could be the error in my code? Is it something like reading a value in a vector at an out-of-bounds index?

I checked on the Solaris platform with R-hub and no segfault.

Then I’m out of guesses. Sorry.

Ok, thanks for your attention anyway.

I'm wondering whether these issues have to do with my C++ code. Because Valgrind never mentions my cpp file in these outputs.

is still what attracts my eye, but I can't tell how your code interacts with it. Stackoverflow might be a better venue for this type of question, since there's much more traffic there on general C/C++ OS compilation issues.

Oh !! There's no problem actually: I deleted the .RData file and the Valgrind diagnostics are clean!

But there's still this problem with the CRAN check on Solaris.

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.