fix for santize address errors

This commit is contained in:
Blake Thompson 2015-12-27 21:40:10 -06:00
parent cb7ed7bc80
commit dfa62c88d8
3 changed files with 18 additions and 4 deletions

View file

@ -294,6 +294,7 @@ opts.AddVariables(
# Note: setting DEBUG=True will override any custom OPTIMIZATION level # Note: setting DEBUG=True will override any custom OPTIMIZATION level
BoolVariable('DEBUG', 'Compile a debug version of Mapnik', 'False'), 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_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()), 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.', ''), ('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']: if env['DEBUG_UNDEFINED']:
env.Append(CXXFLAGS = '-fsanitize=undefined-trap -fsanitize-undefined-trap-on-error -ftrapv -fwrapv') 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 requested, sort LIBPATH and CPPPATH one last time before saving...
if env['PRIORITIZE_LINKING']: if env['PRIORITIZE_LINKING']:
conf.prioritize_paths(silent=True) conf.prioritize_paths(silent=True)

View file

@ -56,7 +56,11 @@ struct set_position_impl
template <typename T0,typename T1> template <typename T0,typename T1>
result_type operator() (T0 & coords, T1 const& pos) const 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 <typename T0,typename T1> template <typename T0,typename T1>
result_type operator() (T0 & coords, T1 const& pos) const 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);
}
} }
}; };

View file

@ -60,8 +60,7 @@ if env['PLUGIN_LINKING'] == 'shared':
SHLIBPREFIX='', SHLIBPREFIX='',
SHLIBSUFFIX='.input', SHLIBSUFFIX='.input',
source=plugin_sources, source=plugin_sources,
LIBS=libraries, LIBS=libraries)
LINKFLAGS=env['CUSTOM_LDFLAGS'])
# if the plugin links to libmapnik ensure it is built first # if the plugin links to libmapnik ensure it is built first
Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME'])) Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))