Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

segfault address 0x1, cause 'memory not mapped' #2950

Closed
4 tasks done
arronlacey opened this issue Oct 20, 2022 · 5 comments
Closed
4 tasks done

segfault address 0x1, cause 'memory not mapped' #2950

arronlacey opened this issue Oct 20, 2022 · 5 comments
Labels
bug Something isn't working needs-repro Issues that are blocked until reporter provides an adequate reproduction third-party Issues involving interaction with a third-party library
Milestone

Comments

@arronlacey
Copy link

Bug description

I am trying to rebuild the vetiver website within a Docker container. Running individual python chunks within the container work fine, but when trying to render the .qmd files I get the following:

$ quarto render index.qmd --to html


processing file: index.qmd
  |..............                                                        |  20%
  ordinary text without R code

  |............................                                          |  40%
label: unnamed-chunk-1
  |..........................................                            |  60%
  ordinary text without R code

  |........................................................              |  80%
label: unnamed-chunk-2 (with options) 
List of 1
 $ engine: chr "python"


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

Traceback:
 1: py_call_impl(callable, dots$args, dots$keywords)
 2: builtins$eval(compiled, globals, locals)
 3: force(expr)
 4: py_capture_output(builtins$eval(compiled, globals, locals))
 5: py_compile_eval(snippet, compile_mode)
 6: reticulate::eng_python(options)
 7: engine(options)
 8: in_dir(input_dir(), expr)
 9: in_input_dir(engine(options))
10: block_exec(params)
11: call_block(x)
12: process_group.block(group)
13: process_group(group)
14: withCallingHandlers(if (tangle) process_tangle(group) else process_group(group),     error = function(e) {        setwd(wd)        cat(res, sep = "\n", file = output %n% "")        message("Quitting from lines ", paste(current_lines(i),             collapse = "-"), " (", knit_concord$get("infile"),             ") ")    })
15: process_file(text, output)
16: knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet)
17: rmarkdown::render(input = input, output_format = output_format,     knit_root_dir = knit_root_dir, params = params, run_pandoc = FALSE,     envir = globalenv())
18: execute(params$input, params$format, params$tempDir, params$libDir,     params$dependencies, params$cwd, params$params, params$resourceDir,     params$handledLanguages, params$markdown)
19: .main()
An irrecoverable exception occurred. R is aborting now ...
root@d8296102c061:/home/conda/r_miniconda_container# 

I removed all python chunks from index.qmd to see if the error is raised, but it runs fine and then it fails in the next python chunk - the first evaluated python chunk in getting_started/index.qmd:

from vetiver.data import mtcars
from sklearn import linear_model

car_mod = linear_model.LinearRegression().fit(mtcars.drop(columns="mpg"), mtcars["mpg"])

Steps to reproduce:

docker pull registry.gitlab.com/arronlacey/r_miniconda_container
docker run --rm -p 8787:8787 registry.gitlab.com/arronlacey/r_miniconda_container
docker exec -it <container name> /bin/bash
git clone https://gitlab.com/arronlacey/r_miniconda_container.git
cd r_miniconda_container
quarto render index.qmd --to html

Dockerfile:

FROM rocker/r-ver:4.2.1

RUN apt-get update
RUN apt-get install -y --no-install-recommends libxt6
RUN apt-get install nano

ENV S6_VERSION=v2.1.0.2
ENV RSTUDIO_VERSION=2022.07.2+576
ENV DEFAULT_USER=rstudio
ENV PANDOC_VERSION=default
ENV QUARTO_VERSION=default

RUN /rocker_scripts/install_rstudio.sh
RUN /rocker_scripts/install_pandoc.sh
RUN /rocker_scripts/install_quarto.sh
RUN quarto install extension --no-prompt quarto-ext/grouped-tabsets

RUN useradd -u 1001 -g rstudio -m conda
USER conda

WORKDIR /home/conda

ENV PATH="/home/conda/miniconda3/bin:${PATH}"
ARG PATH="/home/conda/miniconda3/bin:${PATH}"
ENV MLFLOW_BIN=/home/conda/miniconda3/bin/mlflow
ENV MLFLOW_PYTHON_BIN=/home/conda/miniconda3/bin/python

RUN wget \
    https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \
    && bash Miniconda3-latest-Linux-x86_64.sh -b \
    && rm -f Miniconda3-latest-Linux-x86_64.sh
RUN conda --version

USER root

RUN R -q -e 'install.packages(c("reticulate","vetiver","pins","dplyr","checkmate","quarto","gt","tidymodels","randomForest"))'
ENV PATH "$PATH:/root/.local/share/r-miniconda/bin"
RUN R -q -e 'reticulate::py_install(envname="base",c("vetiver","pins","scikit-learn","pandas","nbformat","nbclient"),pip=TRUE)'
ENV USER="rstudio"

CMD ["/usr/lib/rstudio-server/bin/rserver", "--server-daemonize", "0", "--auth-none", "1"]

EXPOSE 8787

CMD ["/init"]

Host details:


Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.1 LTS
Release:	22.04
Codename:	jammy

Checklist

  • Please include a minimal, fully reproducible example in a single .qmd file? Please provide the whole file rather than the snippet you believe is causing the issue.
  • Please format your issue so it is easier for us to read the bug report.
  • Please document the RStudio IDE version you're running (if applicable), by providing the value displayed in the "About RStudio" main menu dialog?
  • Please document the operating system you're running. If on Linux, please provide the specific distribution.
@arronlacey arronlacey added the bug Something isn't working label Oct 20, 2022
@arronlacey
Copy link
Author

arronlacey commented Oct 20, 2022

interestingly some files will render that include python chunks - i.e. get_started/deploy.qmd but some files don't i.e. get_started/version.qmd.

an offending chunk in get_started/version.qmd is:

#| code-fold: true
#| code-summary: "Show the code from previous steps"
from vetiver.data import mtcars
from vetiver import VetiverModel
from sklearn import linear_model

car_mod = linear_model.LinearRegression().fit(mtcars.drop(columns="mpg"), mtcars["mpg"])

v = VetiverModel(car_mod, model_name = "cars_mpg",
                 save_ptype = True, ptype_data = mtcars)

but this chunk runs fine in deploy.qmd:

#| code-fold: true
#| code-summary: "Show the code from previous steps"
#| output: false

from vetiver.data import mtcars
from vetiver import VetiverModel, vetiver_pin_write
from sklearn import tree
from pins import board_folder

car_mod = tree.DecisionTreeRegressor().fit(mtcars.drop(columns="mpg"), mtcars["mpg"])

v = VetiverModel(car_mod, model_name = "cars_mpg",
                 save_ptype = True, ptype_data = mtcars.drop(columns="mpg"))

model_board = board_folder("pins-py", allow_pickle_read=True)
vetiver_pin_write(model_board, v)

so I'm really at a loss here...

@arronlacey
Copy link
Author

I've isolated this line giving an error when rendering with quarto but works fine when running from a python shell:

car_mod = linear_model.LinearRegression().fit(mtcars.drop(columns="mpg"), mtcars["mpg"])

I only have one python installation in this container so I don't think it's a python issue, rather a quarto_cli issue

@cscheid cscheid added the third-party Issues involving interaction with a third-party library label Oct 20, 2022
@cscheid
Copy link
Collaborator

cscheid commented Oct 20, 2022

I only have one python installation in this container so I don't think it's a python issue, rather a quarto_cli issue

The stack trace you have above shows the segfault happening inside reticulate:

Traceback:
 1: py_call_impl(callable, dots$args, dots$keywords)
 2: builtins$eval(compiled, globals, locals)
 3: force(expr)
 4: py_capture_output(builtins$eval(compiled, globals, locals))
 5: py_compile_eval(snippet, compile_mode)
 6: reticulate::eng_python(options)
...

For the sake of clarification: quarto-cli has no code that uses memory-unsafe languages, so a segfault almost by definition will be coming from somewhere else.

My guess is that the container you're using is somehow misconfiguring some option (or installation) in reticulate, which fails to load dynamically a library, and then has a null pointer instead of a function entry point.

@cscheid cscheid added the needs-repro Issues that are blocked until reporter provides an adequate reproduction label Oct 20, 2022
@eitsupi
Copy link
Contributor

eitsupi commented Oct 20, 2022

Hey, isn't this the issue? rocker-org/rocker-versioned2#471 (comment)
This is tracking on the numpy repo. numpy/numpy#21643
quarto has nothing to do with this issue.

The workaround on rocker/r-ver is to switch the BLAS used in R.
https://rocker-project.org/images/versioned/r-ver.html#switching-blas-implementations

@cscheid cscheid added this to the v1.3 milestone Oct 20, 2022
@arronlacey
Copy link
Author

@eitsupi I think you are correct - so not a quarto issue.

@cscheid cscheid closed this as completed Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs-repro Issues that are blocked until reporter provides an adequate reproduction third-party Issues involving interaction with a third-party library
Projects
None yet
Development

No branches or pull requests

3 participants