Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First attempt at fixing nlohmann doctest compilation error #4499

Merged
merged 3 commits into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"sourceFilesToProcess": null,
"sourceFilesToSkip": [
],
"additionalIncludeDirectories": [
"../../azure-core/inc"
],
"additionalCompilerSwitches": [
"-D_azure_APIVIEW",
"-D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH"
],
"allowInternal": true,
"includeDetail": false,
"includePrivate": false,
"filterNamespace": "Azure::",
"reviewName": "Azure Core Tracing Open-Telemetry API Review",
"serviceName": null,
"packageName": "azure-core-tracing-opentelemetry-cpp"
}
3 changes: 2 additions & 1 deletion sdk/core/azure-core/inc/ApiViewSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"additionalCompilerSwitches": [
"-DBUILD_CURL_HTTP_TRANSPORT_ADAPTER",
"-DBUILD_TRANSPORT_WINHTTP_ADAPTER",
"-DCURL_STATICLIB"
"-DCURL_STATICLIB",
"-D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH"
],
"allowInternal": true,
"includeDetail": false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3930,6 +3930,8 @@ namespace {
struct FatalConditionHandler
{
void reset() {}
static void allocateAltStackMem() {}
static void freeAltStackMem() {}
};
#else // DOCTEST_CONFIG_POSIX_SIGNALS || DOCTEST_CONFIG_WINDOWS_SEH

Expand Down Expand Up @@ -3966,6 +3968,9 @@ namespace {
return EXCEPTION_CONTINUE_SEARCH;
}

static void allocateAltStackMem() {}
static void freeAltStackMem() {}

FatalConditionHandler() {
isSet = true;
// 32k seems enough for doctest to handle stack overflow,
Expand Down Expand Up @@ -4018,7 +4023,8 @@ namespace {
static bool isSet;
static struct sigaction oldSigActions[DOCTEST_COUNTOF(signalDefs)];
static stack_t oldSigStack;
static char altStackMem[4 * SIGSTKSZ];
static size_t altStackSize;
static char * altStackMem;

static void handleSignal(int sig) {
const char* name = "<unknown signal>";
Expand All @@ -4034,11 +4040,18 @@ namespace {
raise(sig);
}

static void allocateAltStackMem() {
altStackMem = new char[altStackSize];
}
static void freeAltStackMem() {
delete[] altStackMem;
}

FatalConditionHandler() {
isSet = true;
stack_t sigStack;
sigStack.ss_sp = altStackMem;
sigStack.ss_size = sizeof(altStackMem);
sigStack.ss_size = altStackSize;
sigStack.ss_flags = 0;
sigaltstack(&sigStack, &oldSigStack);
struct sigaction sa = {};
Expand All @@ -4063,10 +4076,12 @@ namespace {
}
};

bool FatalConditionHandler::isSet = false;
bool FatalConditionHandler::isSet = false;
struct sigaction FatalConditionHandler::oldSigActions[DOCTEST_COUNTOF(signalDefs)] = {};
stack_t FatalConditionHandler::oldSigStack = {};
char FatalConditionHandler::altStackMem[] = {};
stack_t FatalConditionHandler::oldSigStack = {};
size_t FatalConditionHandler::altStackSize = 4 * SIGSTKSZ;
char * FatalConditionHandler::altStackMem = nullptr;


#endif // DOCTEST_PLATFORM_WINDOWS
#endif // DOCTEST_CONFIG_POSIX_SIGNALS || DOCTEST_CONFIG_WINDOWS_SEH
Expand Down Expand Up @@ -5687,7 +5702,10 @@ int Context::run() {
p->cout = &fstr;
}

FatalConditionHandler::allocateAltStackMem();

auto cleanup_and_return = [&]() {
FatalConditionHandler::freeAltStackMem();
if(fstr.is_open())
fstr.close();

Expand Down