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

Add GCC 14 UBSAN container (Fedora 40) #81

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

pachadotdev
Copy link
Contributor

To address #80 and mimic one of the additional CRAN checks.

@gaborcsardi
Copy link
Collaborator

Thanks, we don't need a separate R build for this,if you set -fsanitize=undefined for any recent gcc version, it'll work.

@gaborcsardi
Copy link
Collaborator

 => ERROR [14/14] RUN echo -e 'CC = gcc-14 -std=gnu99 -fsanitize=address,undefined -fno-omit-frame-poin  0.5s
------
 > [14/14] RUN echo -e 'CC = gcc-14 -std=gnu99 -fsanitize=address,undefined -fno-omit-frame-pointer\nFC = gfortran-14 -fsanitize=address' >> ~/.R/Makevars:
0.451 /bin/sh: line 1: /root/.R/Makevars: No such file or directory

@gaborcsardi
Copy link
Collaborator

Can you please build this image and make sure that it works, i.e. it finds the error in your package, and also in some other packages with gcc-ubsan and gcc-asan errors on CRAN? Thanks!

@pachadotdev
Copy link
Contributor Author

Can you please build this image and make sure that it works, i.e. it finds the error in your package, and also in some other packages with gcc-ubsan and gcc-asan errors on CRAN? Thanks!

hi @gaborcsardi
I pushed what I had in local (i.e., "gcc" instead of "gcc-14")
Your current image does not support SAN, unless I install libubsan and modify the envvars.
This image does exactly that.

@gaborcsardi
Copy link
Collaborator

So can you try to make sure that this image reproduces the errors on CRAN?
https://www.stats.ox.ac.uk/pub/bdr/memtests/gcc-ASAN/iClusterVB/
https://www.stats.ox.ac.uk/pub/bdr/memtests/gcc-ASAN/quantreg/

Copy link
Collaborator

@gaborcsardi gaborcsardi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

builder/Dockerfile.fedora-gcc14-ubsan Outdated Show resolved Hide resolved
containers/gcc14-ubsan/Dockerfile Outdated Show resolved Hide resolved
'install.packages("pak", repos = sprintf("https://r-lib.github.io/p/pak/%s/%s/%s/%s", "devel", .Platform$pkgType, R.Version()$os, R.Version()$arch))'

# ------------------------------------------------------------------------------------
# Install pkgbuild, rcmdcheck, and decor
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed? It is also error prone, because install.packages() does not error on installation failures.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really needed
the pak part was copied from the gcc14 dockerfile

# adapted from https://www.stats.ox.ac.uk/pub/bdr/memtests/README.txt

RUN mkdir -p ~/.R/ && echo -e 'CC=gcc -std=gnu11 -fsanitize=address,undefined -fno-omit-frame-pointer\nFC=gfortran -fsanitize=address' >> ~/.R/Makevars
ENV LD_PRELOAD=/usr/lib64/libasan.so.8
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this as a global env var is not great, because all programs are going to use it, and the whole system will be very slow.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that was to avoid warnings like "libasan not loaded 1st"

@pachadotdev
Copy link
Contributor Author

I modified my PR to use the existing image with minimal changes

This is how I can imitate the CRAN setup (https://www.stats.ox.ac.uk/pub/bdr/memtests/README.txt)

# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

name: R package

permissions: read-all

jobs:
  R-CMD-check:
    runs-on: ${{ matrix.config.os }}
    container: ${{ matrix.config.container }}

    name: ${{ matrix.config.name }}

    strategy:
      fail-fast: false
      matrix:
        config:
          - {os: ubuntu-latest, container: { image: 'ghcr.io/r-hub/containers/gcc13:latest' }, name: 'gcc14'}
          - {os: ubuntu-latest, container: { image: 'your-docker-image:latest' }, name: 'fedora-gcc14'}

    env:
      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
      R_KEEP_PKG_SOURCE: yes
      ASAN_OPTIONS: 'detect_leaks=0'
      UBSAN_OPTIONS: 'print_stacktrace=1'
      RJAVA_JVM_STACK_WORKAROUND: 0
      RGL_USE_NULL: true
      R_DONT_USE_TK: true
      LD_PRELOAD: /usr/lib64/libasan.so.8

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Set up R environment
        run: |
          mkdir -p ~/.R/
          echo 'CC=gcc -std=gnu11 -fsanitize=address,undefined -fno-omit-frame-pointer' >> ~/.R/Makevars
          echo 'FC=gfortran -fsanitize=address' >> ~/.R/Makevars

      - name: Restore R package cache
        uses: actions/cache@v4
        with:
          path: ~/.cache/R
          key: ${{ runner.os }}-r-${{ matrix.config.r }}-cache

      - name: Install dependencies
        run: |
          Rscript -e 'if (!requireNamespace("pak", quietly = TRUE)) { install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/") }'
          Rscript -e 'pak::pkg_install("decor", dependencies = TRUE)'
          Rscript -e 'pak::pkg_install("rcmdcheck", dependencies = TRUE)'
          Rscript -e 'pak::pkg_install("pkgbuild", dependencies = TRUE)'
          Rscript -e 'pak::pkg_install(".", dependencies = TRUE)'
        working-directory: ./rpkg
        
      - name: Check
        run: |
          Rscript -e 'pkgbuild::check_build_tools(debug = TRUE)'
          Rscript -e 'rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), build_args = "--no-manual", error_on = "error")'
        working-directory: ./rpkg

      - name: Save R package cache
        uses: actions/cache@v4
        with:
          path: ~/.cache/R
          key: ${{ runner.os }}-r-${{ matrix.config.r }}-cache

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants