2

I am running an Rscipt which calculates economic parameters for around 1000 cities in a loop. The data is stored in MySQL which I am accessing using RMySQL and DBI packages.

However I keep getting segmentation fault errors. I have no idea why this happens. Most of the time the script works fine but all of a sudden it throws segmentation fault error. When I rerun the script it works fine again. From what I am able to gather its some kind of memory issue. I tried debugging it using valgrind, but I am not able to understand the output and remedial action which needs to be taken.

Here is the output from valgrind. I want to know what the output means and where the error is.

==5856== Invalid read of size 1
==5856==    at 0x4F3CF17: ??? (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4F3EF2B: Rf_cons (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4EDF18B: ??? (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4EDFF66: Rf_shallow_duplicate (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4EB9CBB: ??? (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4F4276B: ??? (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4F43D24: ??? (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4F019FA: ??? (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4F0CF6F: ??? (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4F1249C: Rf_applyClosure (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4F0D065: ??? (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4F0D38F: ??? (in /usr/lib/R/lib/libR.so)
==5856==  Address 0x122ca7f3 is 3 bytes inside a block of size 296 free'd
==5856==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5856==    by 0x4F3D707: ??? (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4F3EF2B: Rf_cons (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4E82027: ??? (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4E86414: Rf_namesgets (in /usr/lib/R/lib/libR.so)
==5856==    by 0xCB18756: RS_DBI_createNamedList (RS-DBI.c:731)
==5856==    by 0xCB1BB0B: RS_MySQL_resultSetInfo (RS-MySQL.c:1029)
==5856==    by 0x4ECD51B: ??? (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4F0D5A2: ??? (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4F10955: ??? (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4F0D38F: ??? (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4F10BA1: ??? (in /usr/lib/R/lib/libR.so)
==5856== 
==5856== Invalid read of size 8
==5856==    at 0x4F3CF23: ??? (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4F3EF2B: Rf_cons (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4EDF18B: ??? (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4EDFF66: Rf_shallow_duplicate (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4EB9CBB: ??? (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4F4276B: ??? (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4F43D24: ??? (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4F019FA: ??? (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4F0CF6F: ??? (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4F1249C: Rf_applyClosure (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4F0D065: ??? (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4F0D38F: ??? (in /usr/lib/R/lib/libR.so)
==5856==  Address 0x122ca808 is 24 bytes inside a block of size 296 free'd
==5856==    at 0x4C2BDEC: free (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==5856==    by 0x4F3D707: ??? (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4F3EF2B: Rf_cons (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4E82027: ??? (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4E86414: Rf_namesgets (in /usr/lib/R/lib/libR.so)
==5856==    by 0xCB18756: RS_DBI_createNamedList (RS-DBI.c:731)
==5856==    by 0xCB1BB0B: RS_MySQL_resultSetInfo (RS-MySQL.c:1029)
==5856==    by 0x4ECD51B: ??? (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4F0D5A2: ??? (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4F10955: ??? (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4F0D38F: ??? (in /usr/lib/R/lib/libR.so)
==5856==    by 0x4F10BA1: ??? (in /usr/lib/R/lib/libR.so)

This is my session info when I started the run.

R version 3.1.1 (2014-07-10)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] pryr_0.1.2         gdata_2.17.0       lubridate_1.3.3    dplyr_0.2         
 [5] DataCombine_0.1.26 quantmod_0.4-0     Defaults_1.1-1     TTR_0.22-0        
 [9] xts_0.9-7          zoo_1.7-11         RMySQL_0.9-3       DBI_0.2-7         

loaded via a namespace (and not attached):
 [1] assertthat_0.1   codetools_0.2-8  data.table_1.9.2 digest_0.6.8    
 [5] grid_3.1.1       gtools_3.5.0     lattice_0.20-31  memoise_0.2.1   
 [9] parallel_3.1.1   plyr_1.8.1       Rcpp_0.11.2      reshape2_1.4    
[13] stringr_0.6.2    tools_3.1.1     
>
Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
kum
  • 21
  • 1
  • 1
    You should try to build a minimal reproducible example that shows your issue and send it to the package maintainer. It seems that you didn't write compiled code on your own, so if there is a segfault error it likely comes from RMySQL. – nicola Jun 13 '16 at 06:00

0 Answers0