尝试解析Shiny Server中的xml doc时的Segfault

时间:2018-03-26 17:01:35

标签: r xml shiny shiny-server xml2

Greetings Stack Overflow社区!

我正在尝试使用Shiny Server和xml2包解析上传的xml文档,并且我不断收到段错误(内存未映射)。如果我在闪亮的应用程序中定义一个xml对象并使用xml_text函数,没有问题。在Shiny上本地运行时,没有问题。我在使用XML包而不是xml2包时也看到了同样的错误 - 让我相信xml文件上传过程中发生了一些事情,导致闪亮的服务器无法正确映射/解析。我确信有一个简单的解决办法,但我在我的智慧结束。感谢任何帮助 - 谢谢!

每次都会导致错误的简化闪亮应用:

import pyshark

cap = pyshark.FileCapture('arpscan.pcap',display_filter='arp.opcode==1 && arp.dst.hw_mac==00:00:00:00:00:00',only_summaries=True)
count=0
for pkt in cap:
    count=count+1

if count>10:
    print (" ")
    print ("Someone is scanning your network!\n\n")
    print ("For Attacker's Ip, visit 'Tell' section in summary below\n\n ")
    print("----Further details----")
    print "No of ARP Request Packet Received: ", count
    print("----Summary of ARP packet Received---")
    for pkt in cap:
        print (pkt)
else: 
    print ("No ARP scan identified!")

潜入Linux服务器时

错误日志:

library(shiny)
library(xml2)

ui <- fluidPage(
  fileInput("File", "Choose file"),
  tableOutput("Data")
)

server <- function(input, output, session) {
  Data <- eventReactive(input$File, {
    read_xml(input$File$datapath)
    
  })
  
  output$Data <- renderTable({
    head(xml_text(Data()))
  })
  
}

shinyApp(ui, server)

在Shiny应用程序的服务器端定义xml doc时没有错误

*** caught segfault ***
address 0x3b00000000, cause 'memory not mapped'

Traceback:
 1: .Call(`_xml2_doc_parse_file`, path, encoding, as_html, options)
 2: doc_parse_file(con, encoding = encoding, as_html = as_html, options = option
s)
 3: read_xml.character(input$File$datapath)
 4: read_xml(input$File$datapath)
 5: eventReactiveHandler(...)
 6: ..stacktraceon..(eventReactiveHandler(...))
 7: handlerFunc()
 8: ..stacktraceon..(expr)
 9: contextFunc()
10: env$runWith(self, func)
11: withReactiveDomain(.domain, {    env <- .getReactiveEnvironment()    .graphE
nterContext(id)    on.exit(.graphExitContext(id), add = TRUE)    env$runWith(sel
f, func)})
12: ctx$run(function() {    ..stacktraceon..(expr)})
13: ..stacktraceoff..(ctx$run(function() {    ..stacktraceon..(expr)}))
14: isolate(handlerFunc())
15: `<reactive:eventReactive(input$File)>`(...)
16: .func()
17: withVisible(.func())
18: withCallingHandlers({    .error <<- FALSE    withVisible(.func())}, error = function(cond) {
    .value <<- cond    .error <<- TRUE    .visible <<- FALSE})
19: contextFunc()
20: env$runWith(self, func)
21: withReactiveDomain(.domain, {    env <- .getReactiveEnvironment()    .graphEnterContext(id)
   on.exit(.graphExitContext(id), add = TRUE)    env$runWith(self, func)})
22: ctx$run(function() {    result <- withCallingHandlers({        .error <<- FALSE        withV
isible(.func())    }, error = function(cond) {        .value <<- cond        .error <<- TRUE
    .visible <<- FALSE    })    .value <<- result$value    .visible <<- result$visible})
23: self$.updateValue()
24: ..stacktraceoff..(self$.updateValue())
25: Data()
26: xml_text(Data())
27: head(xml_text(Data()))
28: renderTable(...)
29: func()
30: origRenderFunc(...)
31: `output$Data`(...)
32: ..stacktraceon..(`output$Data`(...))
33: orig(name = name, shinysession = self)
34: func()
35: withCallingHandlers(expr, error = function(e) {    if (is.null(attr(e, "stack.trace", exact
= TRUE))) {        calls <- sys.calls()        attr(e, "stack.trace") <- calls        stop(e)
 }})
36: captureStackTraces(expr)
37: withCallingHandlers(captureStackTraces(expr), error = function(e) {    if (inherits(e, "shin
y.silent.error"))         return()    handle <- getOption("shiny.error")    if (is.function(hand
le))         handle()})
38: shinyCallingHandlers(func())
39: doTryCatch(return(expr), name, parentenv, handler)
40: tryCatchOne(expr, names, parentenv, handlers[[1L]])
41: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
42: doTryCatch(return(expr), name, parentenv, handler)
43: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),     names[nh], parente
nv, handlers[[nh]])
44: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
45: doTryCatch(return(expr), name, parentenv, handler)
46: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),     names[nh], parente
nv, handlers[[nh]])
47: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
48: doTryCatch(return(expr), name, parentenv, handler)
49: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),     names[nh], parente
nv, handlers[[nh]])
50: tryCatchList(expr, classes, parentenv, handlers)
51: tryCatch(shinyCallingHandlers(func()), shiny.custom.error = function(cond) {    if (isTRUE(g
etOption("show.error.messages")))         printError(cond)    structure(list(), class = "try-err
or", condition = cond)}, shiny.output.cancel = function(cond) {    structure(list(), class = "ca
ncel-output")}, shiny.silent.error = function(cond) {    structure(list(), class = "try-error",
condition = cond)}, error = function(cond) {    if (isTRUE(getOption("show.error.messages")))
      printError(cond)    if (getOption("shiny.sanitize.errors", FALSE)) {        cond <- simple
Error(paste("An error has occurred. Check your",             "logs or contact the app author for
", "clarification."))    }    invisible(structure(list(), class = "try-error", condition = cond)
)}, finally = {    private$sendMessage(recalculating = list(name = name, status = "recalculated"
))})
52: observerFunc()
53: doTryCatch(return(expr), name, parentenv, handler)
54: tryCatchOne(expr, names, parentenv, handlers[[1L]])
55: tryCatchList(expr, classes, parentenv, handlers)
56: tryCatch(if (..stacktraceon) ..stacktraceon..(observerFunc()) else observerFunc(),     shiny
.silent.error = function(e) NULL)
57: contextFunc()
58: env$runWith(self, func)
59: withReactiveDomain(.domain, {    env <- .getReactiveEnvironment()    .graphEnterContext(id)
   on.exit(.graphExitContext(id), add = TRUE)    env$runWith(self, func)})
60: ctx$run(.func)
61: run()
62: withCallingHandlers(expr, error = function(e) {    if (is.null(attr(e, "stack.trace", exact
= TRUE))) {        calls <- sys.calls()        attr(e, "stack.trace") <- calls        stop(e)
 }})
63: captureStackTraces(expr)
64: withCallingHandlers(captureStackTraces(expr), error = function(e) {    if (inherits(e, "shin
y.silent.error"))         return()    handle <- getOption("shiny.error")    if (is.function(hand
le))         handle()})
65: shinyCallingHandlers(run())
66: doTryCatch(return(expr), name, parentenv, handler)
67: tryCatchOne(expr, names, parentenv, handlers[[1L]])
68: tryCatchList(expr, classes, parentenv, handlers)
69: tryCatch({    if (!.destroyed)         shinyCallingHandlers(run())}, error = function(e) {
  printError(e)    if (!is.null(.domain)) {        .domain$unhandledError(e)    }})
70: flushCallback()
71: FUN(X[[i]], ...)
72: lapply(.flushCallbacks, function(flushCallback) {    flushCallback()})
73: ctx$executeFlushCallbacks()
74: .getReactiveEnvironment()$flush()
75: flushReact()
76: force(expr)
77: withRestoreContext(shinysession$restoreContext, {    msg$data <- applyInputHandlers(msg$data
)    switch(msg$method, init = {        serverFunc <- withReactiveDomain(NULL, serverFuncSource(
))        if (!identicalFunctionBodies(serverFunc, appvars$server)) {            appvars$server
<- serverFunc            if (!is.null(appvars$server)) {                attr(appvars$server, "sh
inyServerFunction") <- TRUE                registerDebugHook("server", appvars, "Server Function
")            }        }        if (.globals$showcaseOverride && exists(".clientdata_url_search"
,             where = msg$data)) {            mode <- showcaseModeOfQuerystring(msg$data$.client
data_url_search)            if (!is.null(mode)) shinysession$setShowcase(mode)        }        s
hinysession$manageInputs(msg$data)        if (!is.null(msg$data$.clientdata_singletons)) {
      shinysession$singletons <- strsplit(msg$data$.clientdata_singletons,                 ",")[
[1]]        }        local({            args <- argsForServerFunc(serverFunc, shinysession)
       withReactiveDomain(shinysession, {                do.call(wrapFunctionLabel(appvars$serve
r, "server",                   ..stacktraceon = TRUE), args)            })        })    }, updat
e = {        shinysession$manageInputs(msg$data)    }, shinysession$dispatch(msg))    shinysessi
on$manageHiddenOutputs()    if (exists(".shiny__stdout", globalenv()) && exists("HTTP_GUID",
     ws$request)) {        shiny_stdout <- get(".shiny__stdout", globalenv())        writeLines(
paste("_n_flushReact ", get("HTTP_GUID", ws$request),             " @ ", sprintf("%.3f", as.nume
ric(Sys.time())), sep = ""),             con = shiny_stdout)        flush(shiny_stdout)        f
lushReact()        writeLines(paste("_x_flushReact ", get("HTTP_GUID", ws$request),
" @ ", sprintf("%.3f", as.numeric(Sys.time())), sep = ""),             con = shiny_stdout)
  flush(shiny_stdout)    }    else {        flushReact()    }    flushAllSessions()})
78: withReactiveDomain(shinysession, {    if (is.character(msg))         msg <- charToRaw(msg)
  traceOption <- getOption("shiny.trace", FALSE)    if (isTRUE(traceOption) || traceOption == "r
ecv") {        if (binary)             message("RECV ", "$$binary data$$")        else message("
RECV ", rawToChar(msg))    }    if (isEmptyMessage(msg))         return()    msg <- decodeMessag
e(msg)    if (is.null(shinysession$restoreContext)) {        bookmarkStore <- getShinyOption("bo
okmarkStore", default = "disable")        if (bookmarkStore == "disable") {            shinysess
ion$restoreContext <- RestoreContext$new()        }        else {            shinysession$restor
eContext <- RestoreContext$new(msg$data$.clientdata_url_search)        }    }    withRestoreCont
ext(shinysession$restoreContext, {        msg$data <- applyInputHandlers(msg$data)        switch
(msg$method, init = {            serverFunc <- withReactiveDomain(NULL, serverFuncSource())
       if (!identicalFunctionBodies(serverFunc, appvars$server)) {                appvars$server
 <- serverFunc                if (!is.null(appvars$server)) {                  attr(appvars$serv
er, "shinyServerFunction") <- TRUE                  registerDebugHook("server", appvars, "Server
 Function")                }            }            if (.globals$showcaseOverride && exists(".c
lientdata_url_search",                 where = msg$data)) {                mode <- showcaseModeO
fQuerystring(msg$data$.clientdata_url_search)                if (!is.null(mode)) shinysession$se
tShowcase(mode)            }            shinysession$manageInputs(msg$data)            if (!is.n
ull(msg$data$.clientdata_singletons)) {                shinysession$singletons <- strsplit(msg$d
ata$.clientdata_singletons,                   ",")[[1]]            }            local({
       args <- argsForServerFunc(serverFunc, shinysession)                withReactiveDomain(shi
nysession, {                  do.call(wrapFunctionLabel(appvars$server, "server",
      ..stacktraceon = TRUE), args)                })            })        }, update = {
    shinysession$manageInputs(msg$data)        }, shinysession$dispatch(msg))        shinysessio
n$manageHiddenOutputs()        if (exists(".shiny__stdout", globalenv()) && exists("HTTP_GUID",
            ws$request)) {            shiny_stdout <- get(".shiny__stdout", globalenv())
    writeLines(paste("_n_flushReact ", get("HTTP_GUID",                 ws$request), " @ ", spri
ntf("%.3f", as.numeric(Sys.time())),                 sep = ""), con = shiny_stdout)            f
lush(shiny_stdout)            flushReact()            writeLines(paste("_x_flushReact ", get("HT
TP_GUID",                 ws$request), " @ ", sprintf("%.3f", as.numeric(Sys.time())),
       sep = ""), con = shiny_stdout)            flush(shiny_stdout)        }        else {
       flushReact()        }        flushAllSessions()    })})
79: messageHandler(binary, msg)
80: withCallingHandlers(expr, error = function(e) {    if (is.null(attr(e, "stack.trace", exact
= TRUE))) {        calls <- sys.calls()        attr(e, "stack.trace") <- calls        stop(e)
 }})
81: captureStackTraces(expr)
82: withCallingHandlers(captureStackTraces(expr), error = function(cond) {    if (inherits(cond,
 "shiny.silent.error"))         return()    if (isTRUE(getOption("show.error.messages"))) {
   printError(cond, full = full, offset = offset)    }})
83: withLogErrors(messageHandler(binary, msg))
84: handler(binary, message)
85: doTryCatch(return(expr), name, parentenv, handler)
86: tryCatchOne(expr, names, parentenv, handlers[[1L]])
87: tryCatchList(expr, classes, parentenv, handlers)
88: tryCatch(expr, error = function(e) {    call <- conditionCall(e)    if (!is.null(call)) {
     if (identical(call[[1L]], quote(doTryCatch)))             call <- sys.call(-4L)        dcal
l <- deparse(call)[1L]        prefix <- paste("Error in", dcall, ": ")        LONG <- 75L
 msg <- conditionMessage(e)        sm <- strsplit(msg, "\n")[[1L]]        w <- 14L + nchar(dcall
, type = "w") + nchar(sm[1L], type = "w")        if (is.na(w))             w <- 14L + nchar(dcal
l, type = "b") + nchar(sm[1L],                 type = "b")        if (w > LONG)             pref
ix <- paste0(prefix, "\n  ")    }    else prefix <- "Error : "    msg <- paste0(prefix, conditio
nMessage(e), "\n")    .Internal(seterrmessage(msg[1L]))    if (!silent && identical(getOption("s
how.error.messages"),         TRUE)) {        cat(msg, file = outFile)        .Internal(printDef
erredWarnings())    }    invisible(structure(msg, class = "try-error", condition = e))})
89: try(handler(binary, message))
90: (function (handle, binary, message) {    for (handler in .wsconns[[as.character(handle)]]$.m
essageCallbacks) {        result <- try(handler(binary, message))        if (inherits(result, "t
ry-error")) {            .wsconns[[as.character(handle)]]$close()            return()        }
  }})("75427280", FALSE, "{\"method\":\"uploadEnd\",\"args\":[\"d1c9e805d125c4009e9a54fa\",\"Fil
e\"],\"tag\":1}")
91: evalq((function (handle, binary, message) {    for (handler in .wsconns[[as.character(handle
)]]$.messageCallbacks) {        result <- try(handler(binary, message))        if (inherits(resu
lt, "try-error")) {            .wsconns[[as.character(handle)]]$close()            return()
   }    }})("75427280", FALSE, "{\"method\":\"uploadEnd\",\"args\":[\"d1c9e805d125c4009e9a54fa\"
,\"File\"],\"tag\":1}"),     <environment>)
92: evalq((function (handle, binary, message) {    for (handler in .wsconns[[as.character(handle
)]]$.messageCallbacks) {        result <- try(handler(binary, message))        if (inherits(resu
lt, "try-error")) {            .wsconns[[as.character(handle)]]$close()            return()
   }    }})("75427280", FALSE, "{\"method\":\"uploadEnd\",\"args\":[\"d1c9e805d125c4009e9a54fa\"
,\"File\"],\"tag\":1}"),     <environment>)
93: doTryCatch(return(expr), name, parentenv, handler)
94: tryCatchOne(expr, names, parentenv, handlers[[1L]])
95: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
96: doTryCatch(return(expr), name, parentenv, handler)
97: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]),     names[nh], parente
nv, handlers[[nh]])
98: tryCatchList(expr, classes, parentenv, handlers)
99: tryCatch(evalq((function (handle, binary, message) {    for (handler in .wsconns[[as.charact
er(handle)]]$.messageCallbacks) {        result <- try(handler(binary, message))        if (inhe
rits(result, "try-error")) {            .wsconns[[as.character(handle)]]$close()            retu
rn()        }    }})("75427280", FALSE, "{\"method\":\"uploadEnd\",\"args\":[\"d1c9e805d125c4009
e9a54fa\",\"File\"],\"tag\":1}"),     <environment>), error = function (x) x, interrupt = functi
on (x) x)
100: .Call("httpuv_run", PACKAGE = "httpuv", timeoutMillis)
101: run(timeoutMs)
102: service(timeout)
103: serviceApp()
104: withCallingHandlers(expr, error = function(e) {    if (is.null(attr(e, "stack.trace", exact
 = TRUE))) {        calls <- sys.calls()        attr(e, "stack.trace") <- calls        stop(e)
  }})
105: captureStackTraces({    scheduleFlush()    while (!.globals$stopped) {        serviceApp()
       Sys.sleep(0.001)    }})
106: ..stacktraceoff..(captureStackTraces({    scheduleFlush()    while (!.globals$stopped) {
     serviceApp()        Sys.sleep(0.001)    }}))
107: runApp(Sys.getenv("SHINY_APP"), port = port, launch.browser = FALSE)
An irrecoverable exception occurred. R is aborting now ...
-bash: line 1:  9860 Segmentation fault      (core dumped) R --no-save --slave -f \/opt\/shiny-s
erver\/R\/SockJSAdapter\.R

0 个答案:

没有答案