Skip to content

Commit 28216ac

Browse files
authored
Add tracing to hostpolicy_init_t::init (#118973)
We're hitting an intermittent crash in CI on macOS x64. Without a dump, we just have the trace messages to narrow down where it is happening - seems to be between the start of `hostpolicy_init_t::init` (called by `corehost_load`) and when `corehost_main` is called (right after `corehost_load`). This adds a bunch of tracing to `hostpolicy_init_t::init` (can be removed when we figure out what is going on and where).
1 parent 88aa312 commit 28216ac

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/native/corehost/hostpolicy/hostpolicy_init.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ void make_palstr_arr(size_t argc, const pal::char_t** argv, std::vector<pal::str
1010
out->reserve(argc);
1111
for (size_t i = 0; i < argc; ++i)
1212
{
13+
trace::verbose(_X(" [%zu]: %s"), i, argv[i]);
1314
out->push_back(argv[i]);
1415
}
1516
}
@@ -32,12 +33,16 @@ bool hostpolicy_init_t::init(const host_interface_t* input, hostpolicy_init_t* i
3233

3334
if (input->version_lo >= offsetof(host_interface_t, host_mode) + sizeof(input->host_mode))
3435
{
36+
trace::verbose(_X(" config keys [%zu], values: [%zu]"), input->config_keys.len, input->config_values.len);
3537
make_palstr_arr(input->config_keys.len, input->config_keys.arr, &init->cfg_keys);
3638
make_palstr_arr(input->config_values.len, input->config_values.arr, &init->cfg_values);
3739

3840
init->deps_file = input->deps_file;
3941
init->is_framework_dependent = input->is_framework_dependent;
42+
trace::verbose(_X(" deps_file: %s"), init->deps_file.c_str());
43+
trace::verbose(_X(" is_framework_dependent: %s"), init->is_framework_dependent ? _X("true") : _X("false"));
4044

45+
trace::verbose(_X(" probe paths [%zu]"), input->probe_paths.len);
4146
make_palstr_arr(input->probe_paths.len, input->probe_paths.arr, &init->probe_paths);
4247

4348
init->patch_roll_forward = input->patch_roll_forward;
@@ -56,17 +61,22 @@ bool hostpolicy_init_t::init(const host_interface_t* input, hostpolicy_init_t* i
5661
if (input->version_lo >= offsetof(host_interface_t, tfm) + sizeof(input->tfm))
5762
{
5863
init->tfm = input->tfm;
64+
trace::verbose(_X(" tfm: %s"), init->tfm.c_str());
5965
}
6066

6167
if (input->version_lo >= offsetof(host_interface_t, fx_ver) + sizeof(input->fx_ver))
6268
{
6369
init->additional_deps_serialized = input->additional_deps_serialized;
6470
fx_requested_ver = input->fx_ver;
71+
trace::verbose(_X(" additional_deps_serialized: %s"), init->additional_deps_serialized.c_str());
72+
trace::verbose(_X(" fx_requested_ver: %s"), fx_requested_ver.c_str());
6573
}
6674

6775
if (input->version_lo >= offsetof(host_interface_t, fx_names) + sizeof(input->fx_names))
6876
{
6977
size_t fx_count = input->fx_names.len;
78+
trace::verbose(_X(" frameworks [%zu]"), fx_count);
79+
7080
assert(fx_count > 0);
7181
assert(fx_count == input->fx_dirs.len);
7282
assert(fx_count == input->fx_requested_versions.len);
@@ -85,12 +95,15 @@ bool hostpolicy_init_t::init(const host_interface_t* input, hostpolicy_init_t* i
8595
init->fx_definitions.reserve(fx_count);
8696
for (size_t i = 0; i < fx_count; ++i)
8797
{
98+
trace::verbose(_X(" name='%s', dir='%s', requested_version='%s', found_version='%s'"),
99+
fx_names[i].c_str(), fx_dirs[i].c_str(), fx_requested_versions[i].c_str(), fx_found_versions[i].c_str());
88100
auto fx = new fx_definition_t(fx_names[i], fx_dirs[i], fx_requested_versions[i], fx_found_versions[i]);
89101
init->fx_definitions.push_back(std::unique_ptr<fx_definition_t>(fx));
90102
}
91103
}
92104
else
93105
{
106+
trace::verbose(_X(" older interface version: using fx_dir, fx_name, fx_requested_ver"));
94107
// Backward compat; create the fx_definitions[0] and [1] from the previous information
95108
init->fx_definitions.reserve(2);
96109

@@ -117,17 +130,22 @@ bool hostpolicy_init_t::init(const host_interface_t* input, hostpolicy_init_t* i
117130

118131
// Initialize the host command
119132
init_host_command(input, init);
133+
trace::verbose(_X(" host_command: %s"), init->host_command.c_str());
120134

121135
if (input->version_lo >= offsetof(host_interface_t, host_info_host_path) + sizeof(input->host_info_host_path))
122136
{
123137
init->host_info.host_path = input->host_info_host_path;
124138
init->host_info.dotnet_root = input->host_info_dotnet_root;
125139
init->host_info.app_path = input->host_info_app_path;
126140
// For the backwards compat case, this will be later initialized with argv[0]
141+
trace::verbose(_X(" host_path: %s"), init->host_info.host_path.c_str());
142+
trace::verbose(_X(" dotnet_root: %s"), init->host_info.dotnet_root.c_str());
143+
trace::verbose(_X(" app_path: %s"), init->host_info.app_path.c_str());
127144
}
128145

129146
if (input->version_lo >= offsetof(host_interface_t, single_file_bundle_header_offset) + sizeof(input->single_file_bundle_header_offset))
130147
{
148+
trace::verbose(_X(" single_file_bundle_header_offset: %zu"), input->single_file_bundle_header_offset);
131149
if (input->single_file_bundle_header_offset != 0)
132150
{
133151
static bundle::runner_t bundle_runner(input->host_info_host_path, input->host_info_app_path, input->single_file_bundle_header_offset);

0 commit comments

Comments
 (0)