Skip to content
Permalink
Browse files

Merge pull request #5868 from rouault/memleak_fixes_7_4

Backport of memory leak fixes
  • Loading branch information
rouault committed Sep 13, 2019
2 parents e083004 + 22e120e commit 9762bb8dd8c4407ff6ba1c2ae276969bfe4ab4c6
@@ -4,12 +4,30 @@ branches:

dist: trusty
language: php
php:
- 5.6
- 7.0
- 7.1
- 7.2
- 7.3

matrix:
include:

- php: 5.6
env:
- BUILD_NAME=PHP_5.6

- php: 7.0
env:
- BUILD_NAME=PHP_7.0

- php: 7.1
env:
- BUILD_NAME=PHP_7.1

- php: 7.2
env:
- BUILD_NAME=PHP_7.2_WITH_ASAN

- php: 7.3
env:
- BUILD_NAME=PHP_7.3

cache:
apt: true
directories:
@@ -54,47 +72,13 @@ compiler:
- clang

before_install:
- sudo mv /etc/apt/sources.list.d/pgdg* /tmp
- dpkg -l | grep postgresql
- dpkg -l | grep postgis
- sudo apt-get remove postgresql*
- sudo add-apt-repository -y ppa:ubuntugis/ppa
- sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-testing
- sudo apt-get update
- sudo apt-get install --allow-unauthenticated protobuf-c-compiler libprotobuf-c0-dev bison flex python-lxml libfribidi-dev cmake librsvg2-dev colordiff libpq-dev libpng12-dev libjpeg-dev libgif-dev libgeos-dev libgd2-xpm-dev libfreetype6-dev libfcgi-dev libcurl4-gnutls-dev libcairo2-dev libgdal1-dev libproj-dev libxml2-dev python-dev libexempi-dev lcov lftp postgis libharfbuzz-dev gdal-bin ccache
- sudo apt-get install --allow-unauthenticated libmono-system-drawing4.0-cil mono-mcs
- sudo apt-get install --allow-unauthenticated php5-dev || sudo apt-get install --allow-unauthenticated php7-dev
- sudo apt-get install --allow-unauthenticated libperl-dev
- sudo pip install git+git://github.com/tbonfort/cpp-coveralls.git@extensions
# install swig 3.0.12 (defaults to 2.0.11 on trusty)
- wget http://prdownloads.sourceforge.net/swig/swig-3.0.12.tar.gz
- export CC="ccache gcc"
- export CXX="ccache g++"
- tar xf swig-3.0.12.tar.gz
- cd swig-3.0.12 && ./configure --prefix=/usr && make -j2 && sudo make install
- swig -version
- cd ..
- cd msautotest
- ./create_postgis_test_data.sh
- python -m SimpleHTTPServer &> /dev/null &
- cd ..
- touch maplexer.l
- touch mapparser.y

- ./ci/travis/before_install.sh

script:
- export CC="ccache gcc"
- export CXX="ccache g++"
- make cmakebuild MFLAGS="-j2"
- make mspython-wheel
- make -j4 test
- ./ci/travis/script.sh

after_success:
# Only run coverage when it is safe to do so (not on pull requests), and only on master branch
- echo "$TRAVIS_SECURE_ENV_VARS"
- echo "$TRAVIS_BRANCH"
- sh -c 'if test "$TRAVIS_SECURE_ENV_VARS" = "true" -a "$TRAVIS_BRANCH" = "master"; then echo "run coverage"; ./run_code_coverage_upload.sh; fi'
- coveralls --exclude renderers --exclude mapscript --exclude apache --exclude build/mapscript/mapscriptJAVA_wrap.c --exclude build/mapscript/mapscriptPYTHON_wrap.c --exclude shp2img.c --exclude legend.c --exclude scalebar.c --exclude msencrypt.c --exclude sortshp.c --exclude shptreevis.c --exclude shptree.c --exclude testexpr.c --exclude sym2img.c --exclude testcopy.c --exclude shptreetst.c --exclude tile4ms.c --extension .c --extension .cpp
- ./ci/travis/after_success.sh

notifications:
email:
@@ -1,4 +1,4 @@
AUTOTEST_OPTS=-strict -q
AUTOTEST_OPTS?=-strict -q
PHP_MAPSCRIPT=build/mapscript/php/php_mapscript.so
PYTHON_MAPSCRIPT_PATH=build/mapscript/python
JAVA_MAPSCRIPT_PATH=build/mapscript/java
@@ -7,11 +7,11 @@ PERL_MAPSCRIPT_PATH=build/mapscript/perl
BUILDPATH=../../build
FLEX=flex
YACC=yacc
CMAKEFLAGS=-DCMAKE_C_FLAGS="--coverage" -DCMAKE_CXX_FLAGS="--coverage" \
CMAKEFLAGS=-DCMAKE_C_FLAGS="--coverage ${CMAKE_C_FLAGS}" -DCMAKE_CXX_FLAGS="--coverage ${CMAKE_CXX_FLAGS}" \
-DCMAKE_SHARED_LINKER_FLAGS="-lgcov" -DWITH_CLIENT_WMS=1 \
-DWITH_CLIENT_WFS=1 -DWITH_KML=1 -DWITH_SOS=1 -DWITH_CSHARP=1 -DWITH_PHP=1 -DWITH_PERL=1 \
-DWITH_PYTHON=1 -DWITH_JAVA=1 -DWITH_THREAD_SAFETY=1 -DWITH_FRIBIDI=1 -DWITH_FCGI=0 -DWITH_EXEMPI=1 \
-DCMAKE_BUILD_TYPE=Release -DWITH_RSVG=1 -DWITH_CURL=1 -DWITH_HARFBUZZ=1 -DWITH_POINT_Z_M=1
-DCMAKE_BUILD_TYPE=Release -DWITH_RSVG=1 -DWITH_CURL=1 -DWITH_HARFBUZZ=1 -DWITH_POINT_Z_M=1 ${EXTRA_CMAKEFLAGS}
all: cmakebuild

cmakebuild: lexer parser
@@ -69,6 +69,9 @@ test: cmakebuild
@$(MAKE) $(MFLAGS) csharp-testcase
@$(MAKE) $(MFLAGS) perl-testcase

asan_compatible_tests: cmakebuild
@$(MAKE) $(MFLAGS) wxs-testcase renderers-testcase misc-testcase gdal-testcase query-testcase
@./print-test-results.sh

lexer: maplexer.c
parser: mapparser.c
@@ -0,0 +1,10 @@
#!/bin/sh
set -eu

if [ "$BUILD_NAME" != "PHP_7.2_WITH_ASAN" ]; then
# Only run coverage when it is safe to do so (not on pull requests), and only on master branch
echo "$TRAVIS_SECURE_ENV_VARS"
echo "$TRAVIS_BRANCH"
sh -c 'if test "$TRAVIS_SECURE_ENV_VARS" = "true" -a "$TRAVIS_BRANCH" = "master"; then echo "run coverage"; ./run_code_coverage_upload.sh; fi'
coveralls --exclude renderers --exclude mapscript --exclude apache --exclude build/mapscript/mapscriptJAVA_wrap.c --exclude build/mapscript/mapscriptPYTHON_wrap.c --exclude shp2img.c --exclude legend.c --exclude scalebar.c --exclude msencrypt.c --exclude sortshp.c --exclude shptreevis.c --exclude shptree.c --exclude testexpr.c --exclude sym2img.c --exclude testcopy.c --exclude shptreetst.c --exclude tile4ms.c --extension .c --extension .cpp
fi
@@ -0,0 +1,29 @@
#!/bin/sh
set -eu

sudo mv /etc/apt/sources.list.d/pgdg* /tmp
dpkg -l | grep postgresql
dpkg -l | grep postgis
sudo apt-get remove postgresql*
sudo add-apt-repository -y ppa:ubuntugis/ppa
sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-testing
sudo apt-get update
sudo apt-get install --allow-unauthenticated protobuf-c-compiler libprotobuf-c0-dev bison flex python-lxml libfribidi-dev cmake librsvg2-dev colordiff libpq-dev libpng12-dev libjpeg-dev libgif-dev libgeos-dev libgd2-xpm-dev libfreetype6-dev libfcgi-dev libcurl4-gnutls-dev libcairo2-dev libgdal1-dev libproj-dev libxml2-dev python-dev libexempi-dev lcov lftp postgis libharfbuzz-dev gdal-bin ccache
sudo apt-get install --allow-unauthenticated libmono-system-drawing4.0-cil mono-mcs
sudo apt-get install --allow-unauthenticated php5-dev || sudo apt-get install --allow-unauthenticated php7-dev
sudo apt-get install --allow-unauthenticated libperl-dev
sudo pip install git+git://github.com/tbonfort/cpp-coveralls.git@extensions
# install swig 3.0.12 (defaults to 2.0.11 on trusty)
wget http://prdownloads.sourceforge.net/swig/swig-3.0.12.tar.gz
export CC="ccache gcc"
export CXX="ccache g++"
tar xf swig-3.0.12.tar.gz
cd swig-3.0.12 && ./configure --prefix=/usr && make -j2 && sudo make install
swig -version
cd ..
cd msautotest
./create_postgis_test_data.sh
python -m SimpleHTTPServer &> /dev/null &
cd ..
touch maplexer.l
touch mapparser.y
@@ -0,0 +1,18 @@
#!/bin/sh
set -eu

if [ "$BUILD_NAME" = "PHP_7.2_WITH_ASAN" ]; then
export CC="ccache clang"
export CXX="ccache clang++"
# -DNDEBUG to avoid issues with cairo cleanup
make cmakebuild MFLAGS="-j2" CMAKE_C_FLAGS="-g -fsanitize=address -DNDEBUG" CMAKE_CXX_FLAGS="-g -fsanitize=address -DNDEBUG" EXTRA_CMAKEFLAGS="-DCMAKE_BUILD_TYPE=None -DCMAKE_EXE_LINKER_FLAGS=-fsanitize=address"
export AUTOTEST_OPTS="-q -strict -run_under_asan"
# Only run tests that only involve mapserv/shp2img binaries. mspython, etc would require LD_PREOLOAD'ing the asan shared object
make -j4 asan_compatible_tests
else
export CC="ccache gcc"
export CXX="ccache g++"
make cmakebuild MFLAGS="-j2"
make mspython-wheel
make -j4 test
fi
@@ -204,10 +204,12 @@ int msCopyFontSet(fontSetObj *dst, fontSetObj *src, mapObj *map)

int msCopyExpression(expressionObj *dst, expressionObj *src)
{
if((dst->type == MS_REGEX) && dst->compiled) ms_regfree(&(dst->regex));
dst->compiled = MS_FALSE;

MS_COPYSTRING(dst->string, src->string);
MS_COPYSTELEM(type);
MS_COPYSTELEM(flags);
dst->compiled = MS_FALSE;

return MS_SUCCESS;
}
@@ -6512,6 +6512,7 @@ static int loadMapInternal(mapObj *map)
if(getInteger(&(map->imagequality)) == -1) return MS_FAILURE;
break;
case(IMAGETYPE):
msFree(map->imagetype);
map->imagetype = getToken();
break;
case(INTERLACE):
@@ -6879,6 +6880,7 @@ int msUpdateMapFromURL(mapObj *map, char *variable, char *string)

/* TODO: should validate or does msPostMapParseOutputFormatSetup() do enough? */

msFree(map->imagetype);
map->imagetype = getToken();
msPostMapParseOutputFormatSetup( map );
break;
@@ -105,10 +105,6 @@ void msGDALCleanup( void )
while( iRepeat-- )
CPLPopErrorHandler();

#if GDAL_RELEASE_DATE > 20021001
GDALDestroyDriverManager();
#endif

msReleaseLock( TLOCK_GDAL );

bGDALInitialized = 0;
@@ -251,8 +251,11 @@ int msAddLabelGroup(mapObj *map, imageObj *image, layerObj* layer, int classinde
msPopulateTextSymbolForLabelAndString(ts,lbl,annotext,layerPtr->scalefactor,image->resolutionfactor, 1);

if(annotext && *annotext && lbl->autominfeaturesize && featuresize > 0) {
if(UNLIKELY(MS_FAILURE == msComputeTextPath(map,ts)))
if(UNLIKELY(MS_FAILURE == msComputeTextPath(map,ts))) {
freeTextSymbol(ts);
free(ts);
return MS_FAILURE;
}
if(featuresize < (ts->textpath->bounds.bbox.maxx - ts->textpath->bounds.bbox.minx)) {
/* feature is too big to be drawn, skip it */
freeTextSymbol(ts);
@@ -2106,7 +2106,7 @@ msINLINELayerInfo;

int msINLINELayerIsOpen(layerObj *layer)
{
if (layer->currentfeature)
if (layer->layerinfo)
return(MS_TRUE);
else
return(MS_FALSE);

0 comments on commit 9762bb8

Please sign in to comment.
You can’t perform that action at this time.