stan-dev / stan-dev/rstan

crash/segfault when reusing a model

Open
#388 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
R
Stars
1.1k
Forks
266
Avg merge
2h 56m
Merged PRs (30d)
1

Description

Summary:

R reliably crashes when re-using a pre-compiled/cached model.

Description:

R crashes the 2nd time a model is run, possibly related to #221.

Reproducible Steps:
library(rstan)
stan_demo(1)  # runs fine
stan_demo(1)  # crash here
Current Output:
*** caught segfault ***
address 0x1c, cause 'memory not mapped'

Traceback:
 1: FUN(X[[i]], ...)
 2: lapply(name, function(id) {    v <- .Internal(getSymbolInfo(as.character(id), PACKAGE, as.logical(withRegistrationInfo)))    if (is.null(v)) {        msg <- paste("no such symbol", id)        if (length(pkgName) && nzchar(pkgName))             msg <- paste(msg, "in package", pkgName)        stop(msg, domain = NA)    }    names(v) <- c("name", "address", "package", "numParameters")[seq_along(v)]    v})
 3: getNativeSymbolInfo(name, PACKAGE)
 4: doTryCatch(return(expr), name, parentenv, handler)
 5: tryCatchOne(expr, names, parentenv, handlers[[1L]])
 6: tryCatchList(expr, classes, parentenv, handlers)
 7: tryCatch(getNativeSymbolInfo(name, PACKAGE), error = function(e) e)
 8: Module(module, mustStart = TRUE)
 9: .getModulePointer(x)
10: <S4 object of class "Module">$stan_fit4model658c7fe3d509_ideo_interactions
11: eval(expr, envir, enclos)
12: eval(call("$", mod, paste("stan_fit4", model_cppname, sep = "")))
13: object@mk_cppmodule(object)
14: .local(object, ...)
15: (function (object, ...) {    standardGeneric("sampling")})(object = <S4 object of class "stanmodel">, data = <environment>)
16: (function (object, ...) {    standardGeneric("sampling")})(object = <S4 object of class "stanmodel">, data = <environment>)
17: do.call(sampling, args = dots)
18: stan_demo(1)
Expected Output:

N/A

RStan Version:
> packageVersion("rstan")
[1] ‘2.14.1’
R Version:
> R.version.string
[1] "R version 3.3.2 (2016-10-31)"
Operating System:

OS X 10.11.6

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the two consecutive stan_demo(1) calls and inspect the Module/.getModulePointer and sampling paths shown in the traceback. Compare the first and second model runs, using the reported rstan 2.14.1 and R 3.3.2 environment; done means reusing the cached model no longer produces a segfault.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.