R ffdfappend SIGBUS error

你说的曾经没有我的故事 提交于 2019-12-11 03:59:06

问题


I have an R script which uses the ffbase and ff packages. In Windows the script runs fine. In Linux (different box, higher RAM though) it crashes with a bus (SIGBUS) error.

Windows (Version 6.1.7601) session info:

  1. R version 3.1.0 (2014-04-10)
  2. Platform: x86_64-w64-mingw32/x64 (64-bit)
  3. attached packages: ffbase_0.11.3 ff_2.2-13 bit_1.1-12

Linux (Linux xenja 3.5.0-54-generic #81~precise1-Ubuntu SMP Tue Jul 15 04:02:22 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux) session info:

  1. R version 3.1.1 (2014-07-10)
  2. Platform: x86_64-pc-linux-gnu (64-bit)
  3. attached packages: ffbase_0.11.3 ff_2.2-13 bit_1.1-12

The point where the R script crashes is located within a loop, which repeatedly reads different files contents and concatenates them in an ff data-frame via the ffdfappend function. The loop is the following:

working_dir<-getwd()
for(clan_i in levels(data$clan_id)){
  curr_run_name<-paste('clan_',clan_i,sep='')
  curr_working_dir<-paste(working_dir,curr_run_name,sep='/')
  setwd(curr_working_dir)
  prinsout_score_files<-list.files(pattern="^score_.*\\.ent\\.gz\\.txt$")
  clan_i_scores<-c()
  for(prinsout_score_file_i in prinsout_score_files){
    prinsout_score_i<-read.table(prinsout_score_file_i,header=T, row.names=NULL, stringsAsFactors=F)
    if(nrow(prinsout_score_i) > 0){
      prinsout_score_i$pdb_id<-gsub('.*pdb([^\\.]+).*','\\1',prinsout_score_file_i)
      prinsout_score_i$aa<-factor(prinsout_score_i$aa)
      prinsout_score_i$chain<-factor(prinsout_score_i$chain)
      clan_i_scores<-rbind(clan_i_scores,prinsout_score_i[,!grepl('Neighbors',colnames(prinsout_score_i))])
    }
  }
  if(!is.null(clan_i_scores)){
    clan_i_scores$clan_id<-clan_i
    chr_cols<-attr(which(lapply(clan_i_scores, class) == 'character'), 'names')
    clan_i_scores[,chr_cols]<-lapply(clan_i_scores[,chr_cols], factor)
  }
  if(is.null(clans_scores)){
    if(!is.null(clan_i_scores)){
      clans_scores<-as.ffdf(rbind(clans_scores, clan_i_scores))
    }
  }else{
    if(!is.null(clan_i_scores)){
      clans_scores<-ffdfappend(clans_scores, clan_i_scores)
    }
  }
  setwd(working_dir)
}

When I run the R script in Linux, in standard error the following is written (I have deliberately truncated very long lines with @@@)

    *** caught bus error ***
address 0x7f68c7172000, cause 'non-existent physical address'
Traceback:
1: `[<-.ff`(`*tmp*`, , value = c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L @@@
2: `[<-`(`*tmp*`, , value = c(1L, 1L, 1L, 1L, @@@
3: update.ff(ret, from = initdata, delete = FALSE, bydim = bydim, @@@
4: ff(initdata = initdata, length = length, levels = levels, @@@
5: assign("ret", ff(initdata = initdata, length = length, levels = levels, @@@
6: clone.ff(x, FF_RETURN = TRUE, filename = filename, overwrite = overwrite,     ...)
7: as.ff.default(c(1L, 1L, 1L, @@@
8: as.ff(c(1L, 1L, 1L, @@@ 
9: do.call("as.ff", c(list(xi, vmode = vmodes[[i]]), col_args))
10: FUN(1:12[[10L]], ...)
11: lapply(seq_along(x), function(i, ...) {xi <- x[[i]]    AsIs <- inherits(xi, "AsIs")    if (AsIs) {        oldClass(xi) <- oldClass(xi)[-match("AsIs", oldClass(xi))]        ret <- do.call("as.ff", c(list(xi, vmode = vmodes[[i]]), col_args))        oldClass(ret) <- c("AsIs", oldClass(ret))        ret    }    else { do.call("as.ff", c(list(xi, vmode = vmodes[[i]]), col_args))    }}, ...)
12: as.ffdf.data.frame(dat)
13: as.ffdf(dat)
14: ffdfappend(clans_scores, clan_i_scores)
15: eval(expr, envir, enclos)
16: eval(ei, envir)
17: withVisible(eval(ei, envir))
18: source("shinyprins.R")

When I attach the R script to gdb, I get the following relevant messages at the point of crash:

Program received signal SIGBUS, Bus error.
ff_integer_set (handle=<optimized out>, index=<optimized out>, x=1) at ff.cpp:341
341     ff.cpp: No such file or directory.

gdb backtrace:

0:  ff_integer_set (handle=<optimized out>, index=<optimized out>, x=1) at ff.cpp:341
1:  0x00007f8fd4a07a77 in r_ff_integer_set_vector (ff_=0x69fb748, index_=0x1027d7, nreturn_=<optimized out>, value_=<optimized out>)
at r_ff_addgetset.h:535
2:  0x00007f8fda12b228 in ?? () from /usr/lib/R/lib/libR.so
3:  0x00007f8fda15e2d9 in ?? () from /usr/lib/R/lib/libR.so
4:  0x00007f8fda169f70 in ?? () from /usr/lib/R/lib/libR.so
5:  0x00007f8fda16f49d in Rf_applyClosure () from /usr/lib/R/lib/libR.so
@@@
91: 0x00007f8fda16f49d in Rf_applyClosure () from /usr/lib/R/lib/libR.so
92: 0x00007f8fda164e5f in ?? () from /usr/lib/R/lib/libR.so
93: 0x00007f8fda169f70 in ?? () from /usr/lib/R/lib/libR.so
94: 0x00007f8fda16f49d in Rf_applyClosure () from /usr/lib/R/lib/libR.so
95: 0x00007f8fda16a066 in ?? () from /usr/lib/R/lib/libR.so
96: 0x00007f8fda1937fa in Rf_ReplIteration () from /usr/lib/R/lib/libR.so
97: 0x00007f8fda193b30 in ?? () from /usr/lib/R/lib/libR.so
98: 0x00007f8fda194054 in run_Rmainloop () from /usr/lib/R/lib/libR.so
99: 0x000000000040074b in main ()
100: 0x00007f8fd9ad976d in __libc_start_main (main=0x400730 <main>, argc=1, ubp_av=0x7fff0a0799d8, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fff0a0799c8) at libc-start.c:226
101: 0x000000000040077d in _start ()

When I run the R script with strace I get the following relevant info at the point of crash:

open("/tmp/Rtmpznhr7X/ffdf79f87c5de24b.ff", O_RDWR) = 31
mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_SHARED, 31, 0) = 0x7ff558d88000
munmap(0x7ff558d88000, 65536)           = 0
mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_SHARED, 31, 0x10000) = 0x7ff558d88000
munmap(0x7ff558d88000, 65536)           = 0
mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_SHARED, 31, 0x20000) = 0x7ff558d88000
munmap(0x7ff558d88000, 65536)           = 0
mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_SHARED, 31, 0x30000) = 0x7ff558d88000
munmap(0x7ff558d88000, 65536)           = 0
mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_SHARED, 31, 0x40000) = 0x7ff558d88000
munmap(0x7ff558d88000, 65536)           = 0
mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_SHARED, 31, 0x50000) = 0x7ff558d88000
munmap(0x7ff558d88000, 65536)           = 0
mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_SHARED, 31, 0x60000) = 0x7ff558d88000
munmap(0x7ff558d88000, 65536)           = 0
mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_SHARED, 31, 0x70000) = 0x7ff558d88000
munmap(0x7ff558d88000, 65536)           = 0
mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_SHARED, 31, 0x80000) = 0x7ff558d88000
munmap(0x7ff558d88000, 65536)           = 0
mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_SHARED, 31, 0x90000) = 0x7ff558d88000
munmap(0x7ff558d88000, 65536)           = 0
mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_SHARED, 31, 0xa0000) = 0x7ff558d88000
munmap(0x7ff558d88000, 65536)           = 0
mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_SHARED, 31, 0xb0000) = 0x7ff558d88000
munmap(0x7ff558d88000, 65536)           = 0
mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_SHARED, 31, 0xc0000) = 0x7ff558d88000
munmap(0x7ff558d88000, 65536)           = 0
mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_SHARED, 31, 0xd0000) = 0x7ff558d88000
munmap(0x7ff558d88000, 65536)           = 0
mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_SHARED, 31, 0xe0000) = 0x7ff558d88000
munmap(0x7ff558d88000, 65536)           = 0
mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_SHARED, 31, 0xf0000) = 0x7ff558d88000
munmap(0x7ff558d88000, 65536)           = 0
mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_SHARED, 31, 0x100000) = 0x7ff558d88000
munmap(0x7ff558d88000, 65536)           = 0
mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_SHARED, 31, 0x110000) = 0x7ff558d88000
munmap(0x7ff558d88000, 65536)           = 0
mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_SHARED, 31, 0x120000) = 0x7ff558d88000
munmap(0x7ff558d88000, 65536)           = 0
mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_SHARED, 31, 0x130000) = 0x7ff558d88000
munmap(0x7ff558d88000, 65536)           = 0
mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_SHARED, 31, 0x140000) = 0x7ff558d88000
--- SIGBUS (Bus error) @ 0 (0) ---
write(2, "\n *** caught bus error ***\n", 27) = 27
write(2, "address 0x7ff558d92000, cause 'n"..., 62) = 62
write(2, "\nTraceback:\n", 12)          = 12
write(2, " 1: ", 4)                     = 4
write(2, "`[<-.ff`(`*tmp*`, , value = c(1L"..., 62) = 62

Any advice on how to proceed appreciated.

Thank you very much for your time.

-George.

来源:https://stackoverflow.com/questions/25910746/r-ffdfappend-sigbus-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!