better ubsan testing

This commit is contained in:
Nikita Mikhailov 2021-02-16 22:50:34 +03:00 committed by Nikita Mikhaylov
parent 05cf1b5bc5
commit e78fc3109c
4 changed files with 19 additions and 2 deletions

View File

@ -76,6 +76,16 @@
# endif
#endif
#if !defined(UNDEFINED_BEHAVIOR_SANITIZER)
# if defined(__has_feature)
# if __has_feature(undefined_behavior_sanitizer)
# define UNDEFINED_BEHAVIOR_SANITIZER 1
# endif
# elif defined(__UNDEFINED_BEHAVIOR_SANITIZER__)
# define UNDEFINED_BEHAVIOR_SANITIZER 1
# endif
#endif
#if defined(ADDRESS_SANITIZER)
# define BOOST_USE_ASAN 1
# define BOOST_USE_UCONTEXT 1

View File

@ -11,6 +11,7 @@
#include <Columns/ColumnsNumber.h>
#include <Columns/ColumnArray.h>
#include <Columns/ColumnTuple.h>
#include <Common/NaNUtils.h>
#include <DataTypes/DataTypeArray.h>
#include <DataTypes/IDataType.h>
#include <IO/WriteHelpers.h>
@ -24,6 +25,7 @@ namespace DB
namespace ErrorCodes
{
extern const int BAD_ARGUMENTS;
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
}
namespace bg = boost::geometry;
@ -111,6 +113,9 @@ public:
#ifndef NDEBUG
assert(i < size);
#endif
if (isNaN(first[i]) || isNaN(second[i]))
throw Exception("Point's component must not be NaN", ErrorCodes::ILLEGAL_TYPE_OF_ARGUMENT);
boost::geometry::set<0>(container, first[i]);
boost::geometry::set<1>(container, second[i]);
}

View File

@ -540,7 +540,7 @@ private:
}
}
void parseConstPolygon(const ColumnsWithTypeAndName & arguments, Polygon & out_polygon) const
void NO_SANITIZE_UNDEFINED parseConstPolygon(const ColumnsWithTypeAndName & arguments, Polygon & out_polygon) const
{
if (arguments.size() == 2)
parseConstPolygonFromSingleColumn(arguments, out_polygon);
@ -550,7 +550,7 @@ private:
/// Fix orientation and close rings. It's required for subsequent processing.
boost::geometry::correct(out_polygon);
#if !defined(__clang_analyzer__) /// It does not like boost.
#if !defined(__clang_analyzer__) && !defined(UNDEFINED_BEHAVIOR_SANITIZER) /// It does not like boost.
if (validate)
{
std::string failure_message;

View File

@ -1,3 +1,5 @@
select polygonsUnionCartesian([[[(0., 0.),(0., 3.),(1., 2.9),(2., 2.6),(2.6, 2.),(2.9, 1),(3., 0.),(0., 0.)]]], [[[(1., 1.),(1., 4.),(4., 4.),(4., 1.),(1., 1.)]]]);
SELECT polygonsUnionCartesian([[[(2., 100.0000991821289), (0., 3.), (1., 2.9), (2., 2.6), (2.6, 2.), (2.9, 1), (3., 0.), (100.0000991821289, 2.)]]], [[[(1., 1.), (1000.0001220703125, nan), (4., 4.), (4., 1.), (1., 1.)]]]); -- { serverError 43 }
select polygonsUnionGeographic([[[(4.3613577, 50.8651821), (4.349556, 50.8535879), (4.3602419, 50.8435626), (4.3830299, 50.8428851), (4.3904543, 50.8564867), (4.3613148, 50.8651279)]]], [[[(4.346693, 50.858306), (4.367945, 50.852455), (4.366227, 50.840809), (4.344961, 50.833264), (4.338074, 50.848677), (4.346693, 50.858306)]]]);