From dfa62c88d84de39a5f4e6d45f0964e2b38f7d53c Mon Sep 17 00:00:00 2001 From: Blake Thompson Date: Sun, 27 Dec 2015 21:40:10 -0600 Subject: [PATCH 1/3] 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'])) From 5cd3645cd1c01cc66b51f3378c5e52af523d38a0 Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 5 Jan 2016 16:58:37 +0000 Subject: [PATCH 2/3] keep address-sanitizer happy ref (https://github.com/mapbox/mapnik-vector-tile/pull/171) --- include/mapnik/json/positions_grammar.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/mapnik/json/positions_grammar.hpp b/include/mapnik/json/positions_grammar.hpp index a652e8f59..045b8cf8e 100644 --- a/include/mapnik/json/positions_grammar.hpp +++ b/include/mapnik/json/positions_grammar.hpp @@ -63,10 +63,10 @@ struct set_position_impl struct push_position_impl { using result_type = void; - template + template result_type operator() (T0 & coords, T1 const& pos) const { - if (pos) coords.push_back(*pos); + if (pos) coords.empace_back(*pos); } }; From 7b2da35c0118c978aa029d16b901002306c08e23 Mon Sep 17 00:00:00 2001 From: artemp Date: Tue, 5 Jan 2016 19:52:36 +0000 Subject: [PATCH 3/3] fix typo doh --- include/mapnik/json/positions_grammar.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/mapnik/json/positions_grammar.hpp b/include/mapnik/json/positions_grammar.hpp index 045b8cf8e..153542257 100644 --- a/include/mapnik/json/positions_grammar.hpp +++ b/include/mapnik/json/positions_grammar.hpp @@ -66,7 +66,7 @@ struct push_position_impl template result_type operator() (T0 & coords, T1 const& pos) const { - if (pos) coords.empace_back(*pos); + if (pos) coords.emplace_back(*pos); } };