From dfa62c88d84de39a5f4e6d45f0964e2b38f7d53c Mon Sep 17 00:00:00 2001 From: Blake Thompson Date: Sun, 27 Dec 2015 21:40:10 -0600 Subject: [PATCH] fix for santize address errors --- SConstruct | 6 ++++++ include/mapnik/json/positions_grammar.hpp | 13 +++++++++++-- plugins/input/pgraster/build.py | 3 +-- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/SConstruct b/SConstruct index 05562d9a7..53fe21fc6 100644 --- a/SConstruct +++ b/SConstruct @@ -294,6 +294,7 @@ opts.AddVariables( # Note: setting DEBUG=True will override any custom OPTIMIZATION level BoolVariable('DEBUG', 'Compile a debug version of Mapnik', 'False'), BoolVariable('DEBUG_UNDEFINED', 'Compile a version of Mapnik using clang/llvm undefined behavior asserts', 'False'), + BoolVariable('DEBUG_SANITIZE', 'Compile a version of Mapnik using clang/llvm address sanitation', 'False'), ListVariable('INPUT_PLUGINS','Input drivers to include',DEFAULT_PLUGINS,PLUGINS.keys()), ('WARNING_CXXFLAGS', 'Compiler flags you can set to reduce warning levels which are placed after -Wall.', ''), @@ -1799,6 +1800,11 @@ if not preconfigured: if env['DEBUG_UNDEFINED']: env.Append(CXXFLAGS = '-fsanitize=undefined-trap -fsanitize-undefined-trap-on-error -ftrapv -fwrapv') + if env['DEBUG_SANITIZE']: + env.Append(CXXFLAGS = ['-fsanitize=address']) + env.Append(LINKFLAGS = ['-fsanitize=address']) + + # if requested, sort LIBPATH and CPPPATH one last time before saving... if env['PRIORITIZE_LINKING']: conf.prioritize_paths(silent=True) diff --git a/include/mapnik/json/positions_grammar.hpp b/include/mapnik/json/positions_grammar.hpp index a652e8f59..48121053f 100644 --- a/include/mapnik/json/positions_grammar.hpp +++ b/include/mapnik/json/positions_grammar.hpp @@ -56,7 +56,11 @@ struct set_position_impl template result_type operator() (T0 & coords, T1 const& pos) const { - if (pos) coords = *pos; + if (pos) + { + auto const& p = *pos; + coords = p; + } } }; @@ -66,7 +70,12 @@ struct push_position_impl template result_type operator() (T0 & coords, T1 const& pos) const { - if (pos) coords.push_back(*pos); + if (pos) + { + auto const& p = *pos; + typename T0::value_type p1(p); + coords.emplace_back(p1); + } } }; diff --git a/plugins/input/pgraster/build.py b/plugins/input/pgraster/build.py index 7b859ee5b..7d120e482 100644 --- a/plugins/input/pgraster/build.py +++ b/plugins/input/pgraster/build.py @@ -60,8 +60,7 @@ if env['PLUGIN_LINKING'] == 'shared': SHLIBPREFIX='', SHLIBSUFFIX='.input', source=plugin_sources, - LIBS=libraries, - LINKFLAGS=env['CUSTOM_LDFLAGS']) + LIBS=libraries) # if the plugin links to libmapnik ensure it is built first Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))