<commit_before>// This file is part of the uSTL library, an STL implementation.
//
// Copyright (c) 2005-2009 by <NAME> <<EMAIL>>
// This file is free software, distributed under the MIT License.

#define _GNU_SOURCE 1
#include "stdtest.h"
#include <signal.h>

/// Called when a signal is received.
static void OnSignal (int sig)
{
    cout.flush();
    #if HAVE_STRSIGNAL
	cerr.format ("Fatal error: %s received.\n", strsignal(sig));
    #else
	cerr.format ("Fatal error: system signal %d received.\n", sig);
    #endif
    cerr.flush();
    exit (sig);
}

/// Called by the framework on unrecoverable exception handling errors.
static void Terminate (void)
{
    assert (!"Unrecoverable exception handling error detected.");
    raise (SIGABRT);
    exit (EXIT_FAILURE);
}

/// Called when an exception violates a throw specification.
static void OnUnexpected (void)
{
    cerr << "Fatal internal error: unexpected exception caught.\n";<commit_msg>Add a double signal check to bvts to avoid infinite crashes on corruption<commit_after>// This file is part of the uSTL library, an STL implementation.
//
// Copyright (c) 2005-2009 by <NAME> <<EMAIL>>
// This file is free software, distributed under the MIT License.

#define _GNU_SOURCE 1
#include "stdtest.h"
#include <signal.h>
#include <unistd.h>

/// Called when a signal is received.
static void OnSignal (int sig)
{
    static int doubleSignal = false;
    if (!TestAndSet (&doubleSignal))
	abort();
    alarm (1);
    cout.flush();
    #if HAVE_STRSIGNAL
	cerr.format ("Fatal error: %s received.\n", strsignal(sig));
    #else
	cerr.format ("Fatal error: system signal %d received.\n", sig);
    #endif
    cerr.flush();
    exit (sig);
}

/// Called by the framework on unrecoverable exception handling errors.
static void Terminate (void)
{
    assert (!"Unrecoverable exception handling error detected.");
    raise (SIGABRT);
    exit (EXIT_FAILURE);
}

/// Called when an exception violates a throw specification.
static void OnUnexpected (void)
{
    cerr << "Fatal internal error: unexpected exception caught.\n";
{'fraction_non_alphanumeric': 0.11928811928811929, 'fraction_numerical': 0.00913900913900914, 'mean_word_length': 3.663677130044843, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1146426', 'n_tokens_mistral': 648, 'n_tokens_neox': 622, 'n_words': 243}