Skip to content

Commit cd2f7fa

Browse files
authored
Merge pull request #96 from Flamefire/expectedRegionExits
Add whitelist of regions with no region enter events
2 parents 1a404c5 + e7e6bc2 commit cd2f7fa

2 files changed

Lines changed: 20 additions & 1 deletion

File tree

src/scorepy/events.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#include "events.hpp"
2+
#include <Python.h>
3+
#include <algorithm>
4+
#include <array>
25
#include <iostream>
36
#include <scorep/SCOREP_User_Functions.h>
47
#include <scorep/SCOREP_User_Variables.h>
@@ -39,6 +42,16 @@ void region_begin(const std::string& region_name, std::string module, std::strin
3942
SCOREP_User_RegionEnter(region_handle.value);
4043
}
4144

45+
/// Region names that are known to have no region enter event and should not report an error
46+
/// on region exit
47+
static const std::array<std::string, 2> EXIT_REGION_WHITELIST = {
48+
#if PY_MAJOR_VERSION >= 3
49+
"threading:_bootstrap_inner", "threading:_bootstrap"
50+
#else
51+
"threading:__bootstrap_inner", "threading:__bootstrap"
52+
#endif
53+
};
54+
4255
void region_end(const std::string& region_name)
4356
{
4457
const auto itRegion = regions.find(region_name);
@@ -52,6 +65,12 @@ void region_end(const std::string& region_name)
5265
static SCOREP_User_ParameterHandle scorep_param = SCOREP_USER_INVALID_PARAMETER;
5366
static bool error_printed = false;
5467

68+
if (std::find(EXIT_REGION_WHITELIST.begin(), EXIT_REGION_WHITELIST.end(), region_name) !=
69+
EXIT_REGION_WHITELIST.end())
70+
{
71+
return;
72+
}
73+
5574
if (error_region.value == SCOREP_USER_INVALID_REGION)
5675
{
5776
SCOREP_User_RegionInit(&error_region.value, NULL, &SCOREP_User_LastFileHandle,

test/test_scorep.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ def test_threads(scorep_env, instrumenter):
313313
["--nocompiler", "--instrumenter-type=" + instrumenter],
314314
env=scorep_env)
315315

316-
# assert std_err == "" TODO: Readd when issue #87 is resolved
316+
assert std_err == ""
317317
assert "hello world\n" in std_out
318318
assert "Thread 0 started\n" in std_out
319319
assert "Thread 1 started\n" in std_out

0 commit comments

Comments
 (0)