-nostdlib++

This commit is contained in:
Nikita Mikhaylov 2021-10-05 10:51:49 +00:00
parent ec2b30703e
commit f3c50e563e
3 changed files with 34 additions and 5 deletions

View File

@ -135,6 +135,7 @@ if (ENABLE_FUZZING)
# And we don't want to enable coverage for it.
message (STATUS "Fuzzing instrumentation enabled")
set (FUZZER "libfuzzer")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdlib++")
endif()
# Global libraries

View File

@ -1,2 +1,10 @@
add_executable(execute_query_fuzzer execute_query_fuzzer.cpp)
target_link_libraries(execute_query_fuzzer PRIVATE dbms ${LIB_FUZZING_ENGINE})
target_link_libraries(execute_query_fuzzer PRIVATE
dbms
clickhouse_functions
clickhouse_table_functions
clickhouse_aggregate_functions
clickhouse_dictionaries
clickhouse_dictionaries_embedded
${LIB_FUZZING_ENGINE})

View File

@ -3,6 +3,14 @@
#include <Interpreters/Context.h>
#include "Processors/Executors/PullingPipelineExecutor.h"
#include <Functions/registerFunctions.h>
#include <AggregateFunctions/registerAggregateFunctions.h>
#include <TableFunctions/registerTableFunctions.h>
#include <Storages/registerStorages.h>
#include <Dictionaries/registerDictionaries.h>
#include <Disks/registerDisks.h>
#include <Formats/registerFormats.h>
using namespace DB;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t * data, size_t size)
@ -12,15 +20,27 @@ try
static SharedContextHolder shared_context;
static ContextMutablePtr context;
static size_t execution_count = 0;
++execution_count;
if (execution_count == 1)
auto initialize = [&]() mutable
{
shared_context = Context::createShared();
context = Context::createGlobal(shared_context.get());
context->makeGlobalContext();
context->setApplicationType(Context::ApplicationType::LOCAL);
}
registerFunctions();
registerAggregateFunctions();
registerTableFunctions();
registerStorages();
registerDictionaries();
registerDisks();
registerFormats();
return true;
};
static bool initialized = initialize();
(void) initialized;
auto io = DB::executeQuery(input, context, true, QueryProcessingStage::Complete);