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

Fix uaf #66

Open
wants to merge 14 commits into
base: fix_UAF
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,14 @@ SOLVER/inparam_source

SOLVER/STATIONS

*.gcno
*.gcda
__pycache__
.idea/
MESHER/gitversion.h
Makefile
SOLVER/gitversion.h
SOLVER/inparam_hetero
./inparam_advanced
./inparam_basic

144 changes: 80 additions & 64 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,77 +1,93 @@
language: generic

# Use the trusty environment, since the netcdf packages in 12.04 are broken
dist: trusty
sudo: required

env:
global:
MPI_IMPL=openmpi

matrix:
- GFORTRAN_VERSION=6
BUILD='debug'
- GFORTRAN_VERSION=4.8
EXTRAFLAGS=-fopenmp
BUILD='release'
- GFORTRAN_VERSION=6
EXTRAFLAGS=-fopenmp
BUILD='release'
- GFORTRAN_VERSION=4.7
BUILD='release'
- GFORTRAN_VERSION=4.8
BUILD='release'
- GFORTRAN_VERSION=4.9
BUILD='release'
- GFORTRAN_VERSION=5
BUILD='release'
- GFORTRAN_VERSION=6
BUILD='release'
language: cpp

os: linux

compiler:
- cpp

jobs:
include:
- dist: bionic
env: BUILD='debug'
name: 'Mesher (Debug)'
script: ./TESTING/test_mesher.sh;

# - dist: bionic
# env: BUILD='debug'
# name: 'Solver, internal model (Debug)'
# script: ./TESTING/test_internal.sh;

- dist: bionic
env: BUILD='coverage'
name: 'Solver, coverage'
script: travis_wait 30 ./TESTING/test_debug.sh;

- dist: bionic
env: BUILD='release'
name: 'Mesher (Release)'
script: ./TESTING/test_mesher.sh;

- dist: bionic
env: BUILD='release'
name: 'Solver, internal model (Release)'
script: ./TESTING/test_internal.sh;

- dist: bionic
env: BUILD='release'
name: 'Solver, Aakash''s models (Release)'
script: ./TESTING/test_aakash.sh;


- dist: bionic
env: BUILD='release'
name: 'Solver, external model (Release)'
script: ./TESTING/test_external.sh;

addons:
apt:
packages:
- gfortran
- gcc
- libopenmpi-dev
- libnetcdff-dev
- openmpi-bin

before_install:
- export MINICONDA=$HOME/miniconda
- export PATH="$MINICONDA/bin:$PATH"
- export TRAVIS_PYTHON_VERSION=3.8
- export TEST_DIR=$TRAVIS_BUILD_DIR/TESTING
- hash -r
# Install conda only if necessary
- command -v conda >/dev/null || { wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh;
- source "$MINICONDA/etc/profile.d/conda.sh" || { wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
bash miniconda.sh -b -f -p $MINICONDA; }
- conda update --yes conda
- conda remove --yes -n condaenv --all || echo "Conda not yet installed"
- conda create --yes -n condaenv python=2.7
- conda install --yes -n condaenv pip
- source activate condaenv
# The next couple lines fix a crash with multiprocessing on Travis and are not specific to using Miniconda
- sudo rm -rf /dev/shm
- sudo ln -s /run/shm /dev/shm
- conda install --yes -c obspy obspy # python=2.7
- travis_retry pip install $PIP_DEPS
#Install Gfortran in selected version
- sudo -E apt-add-repository -y "ppa:ubuntu-toolchain-r/test"
- sudo -E apt-get -yq update &>> ~/apt-get-update.log
- sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes install
gfortran-$GFORTRAN_VERSION g++-$GFORTRAN_VERSION tcsh gnuplot
- export TRAVIS_ROOT=$HOME/travis
#- mkdir -p $TRAVIS_ROOT
- wget https://www.geophysik.uni-muenchen.de/~staehler/mpi_builds/mpi_netcdf_gcc$GFORTRAN_VERSION.tar.gz
- tar -xf mpi_netcdf_gcc$GFORTRAN_VERSION.tar.gz -C $HOME
# Get and install OpenMPI
# - ./TRAVIS/install_mpi.sh $TRAVIS_ROOT $MPI_IMPL $GFORTRAN_VERSION > LOG_OpenMPI.log
# Get and install NetCDF4
#- ./TRAVIS/install_netcdf.sh $TRAVIS_ROOT $GFORTRAN_VERSION > LOG_NetCDF4.log
- export PATH="$TRAVIS_ROOT/bin:$PATH"

install: true
- source "$MINICONDA/etc/profile.d/conda.sh"
- hash -r
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
# Useful for debugging any issues with conda
- conda info -a
- conda config --add channels conda-forge
- conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION click netcdf4 scipy
- conda activate test-environment
- pip install --user cpp-coveralls


install:
- ./copytemplates.sh $BUILD
- make -j 4

script:
- ./TRAVIS/test_mesher.sh
- cd TESTING;
- python test_nightly_axisem.py -t 1
- python test_nightly_axisem.py -t 2
- python test_nightly_axisem.py -t 3
- cd ..
- ./submit.py test_prem_ani prem_ani 100.0 --jobtype local --ntheta 2

after_success:
- if [[ $BUILD == 'coverage' ]]; then
coveralls -e SOLVER/UTILS -e MESHER/UTILS -e TESTING -e MANUAL -e SOLVER/background_models.F90 -e SOLVER/kdtree2.f90 -e SOLVER/lateral_heterogeneities.f90 --gcov-options '\-lp';
fi

after_failure:
- tail -n 25 $TRAVIS_BUILD_DIR/runs/*/P?/OUTPUT
- cd $TRAVIS_BUILD_DIR/runs/TEST01/PX
- mpirun -n 4 ./axisem


cache:
apt: true
Expand Down
6 changes: 3 additions & 3 deletions MESHER/background_models.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1966,7 +1966,7 @@ real(kind=dp) function arbitr_sub_solar(r0, param, idom)
call interpolate(interp_vpv(idom), r0, arbitr_sub_solar, success)

case('vph')
if (ext_model_is_anelastic) then
if (ext_model_is_ani) then
call interpolate(interp_vph(idom), r0, arbitr_sub_solar, success)
else
call interpolate(interp_vpv(idom), r0, arbitr_sub_solar, success)
Expand All @@ -1976,14 +1976,14 @@ real(kind=dp) function arbitr_sub_solar(r0, param, idom)
call interpolate(interp_vsv(idom), r0, arbitr_sub_solar, success)

case('vsh')
if (ext_model_is_anelastic) then
if (ext_model_is_ani) then
call interpolate(interp_vsh(idom), r0, arbitr_sub_solar, success)
else
call interpolate(interp_vsv(idom), r0, arbitr_sub_solar, success)
end if

case('eta')
if (ext_model_is_anelastic) then
if (ext_model_is_ani) then
call interpolate(interp_eta(idom), r0, arbitr_sub_solar, success)
else
arbitr_sub_solar = 1.
Expand Down
4 changes: 2 additions & 2 deletions SOLVER/inparam_advanced.TEMPLATE
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ CHECKPOINTING true
# meshes (<10s) running on few cores, setting a value above 256 can require >>10GB of
# memory per CPU. When using CHUNK_TIME_TRACES and many cores, a value larger
# then the number of strain samples might be appropriate.
# Default value: 128
NETCDF_DUMP_BUFFER 128
# Default value: 64
NETCDF_DUMP_BUFFER 64

# Chunking of the kernel wavefields: Default is snapshots to write to contiguous
# regions on the drive. When running on many cores and using collective IO, it
Expand Down
15 changes: 11 additions & 4 deletions SOLVER/nc_helpers.F90
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ subroutine putvar_double1d(ncid, varid, values, start, count)
integer :: dimid(10)
character(len=nf90_max_name) :: varname, dimname

if (count==0) return

status = nf90_inquire_variable(ncid = ncid, &
varid = varid, &
Expand Down Expand Up @@ -167,7 +168,8 @@ subroutine putvar_double1d(ncid, varid, values, start, count)
dimid = dimid(1), &
name = dimname, &
len = dimsize )
if (start + count - 1 > dimsize) then
if (0 < count .and. &
(start + count - 1 > dimsize)) then
write(*,102) mynum, trim(varname), varid, ncid, start, count, dimsize, trim(dimname)
print *, trim(nf90_strerror(status))
stop
Expand Down Expand Up @@ -212,6 +214,8 @@ subroutine putvar_real1d(ncid, varid, values, start, count)
character(len=nf90_max_name) :: varname, dimname


if (count==0) return

status = nf90_inquire_variable(ncid = ncid, &
varid = varid, &
name = varname )
Expand Down Expand Up @@ -255,7 +259,7 @@ subroutine putvar_real1d(ncid, varid, values, start, count)
dimid = dimid(1), &
name = dimname, &
len = dimsize )
if (start + count - 1 > dimsize) then
if ((count > 0) .and. (start + count - 1 > dimsize)) then
write(*,102) mynum, trim(varname), varid, ncid, start, count, dimsize, trim(dimname)
print *, trim(nf90_strerror(status))
stop
Expand Down Expand Up @@ -301,6 +305,8 @@ subroutine putvar_real2d(ncid, varid, values, start, count)
character(len=nf90_max_name) :: varname, dimname


if (product(count)==0) return

status = nf90_inquire_variable(ncid = ncid, &
varid = varid, &
name = varname )
Expand Down Expand Up @@ -353,7 +359,7 @@ subroutine putvar_real2d(ncid, varid, values, start, count)
dimid = dimid(idim), &
name = dimname, &
len = dimsize )
if (start(idim) + count(idim) - 1 > dimsize) then
if ((count(idim) > 0) .and. (start(idim) + count(idim) - 1 > dimsize)) then
write(*,102) mynum, trim(varname), varid, ncid, start(idim), count(idim), &
dimsize, trim(dimname), idim
print *, trim(nf90_strerror(status))
Expand Down Expand Up @@ -405,6 +411,7 @@ subroutine putvar_real3d(ncid, varid, values, start, count)
integer :: dimid(10)
character(len=nf90_max_name) :: varname, dimname

if (product(count)==0) return

status = nf90_inquire_variable(ncid = ncid, &
varid = varid, &
Expand Down Expand Up @@ -458,7 +465,7 @@ subroutine putvar_real3d(ncid, varid, values, start, count)
dimid = dimid(idim), &
name = dimname, &
len = dimsize )
if (start(idim) + count(idim) - 1 > dimsize) then
if ((count(idim) > 0) .and. (start(idim) + count(idim) - 1 > dimsize)) then
write(*,102) mynum, trim(varname), varid, ncid, start(idim), count(idim), &
dimsize, trim(dimname), idim
print *, trim(nf90_strerror(status))
Expand Down