Skip to content

Commit

Permalink
[release/6.0] [Mono] Fix potential crash when handling image load eve…
Browse files Browse the repository at this point in the history
…nt. (dotnet#64911)

Co-authored-by: lateralusX <lateralusX.github@gmail.com>
  • Loading branch information
github-actions[bot] and lateralusX authored Feb 8, 2022
1 parent 4164efb commit dbda62f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/mono/mono/eventpipe/ep-rt-mono.c
Original file line number Diff line number Diff line change
Expand Up @@ -2953,6 +2953,8 @@ get_module_event_data (
module_data->module_flags |= MODULE_FLAGS_NATIVE_MODULE;

module_data->module_il_path = image && image->filename ? image->filename : "";
module_data->module_il_pdb_path = "";
module_data->module_il_pdb_age = 0;

if (image && image->image_info) {
MonoPEDirEntry *debug_dir_entry = (MonoPEDirEntry *)&image->image_info->cli_header.datadir.pe_debug;
Expand Down Expand Up @@ -2994,6 +2996,7 @@ ep_rt_mono_write_event_module_load (MonoImage *image)

if (image) {
ModuleEventData module_data;
memset (&module_data, 0, sizeof (module_data));
if (get_module_event_data (image, &module_data)) {
FireEtwModuleLoad_V2 (
module_data.module_id,
Expand Down Expand Up @@ -3037,6 +3040,7 @@ ep_rt_mono_write_event_module_unload (MonoImage *image)

if (image) {
ModuleEventData module_data;
memset (&module_data, 0, sizeof (module_data));
if (get_module_event_data (image, &module_data)) {
FireEtwModuleUnload_V2 (
module_data.module_id,
Expand Down Expand Up @@ -3095,6 +3099,7 @@ ep_rt_mono_write_event_assembly_load (MonoAssembly *assembly)

if (assembly) {
AssemblyEventData assembly_data;
memset (&assembly_data, 0, sizeof (assembly_data));
if (get_assembly_event_data (assembly, &assembly_data)) {
FireEtwAssemblyLoad_V1 (
assembly_data.assembly_id,
Expand All @@ -3121,6 +3126,7 @@ ep_rt_mono_write_event_assembly_unload (MonoAssembly *assembly)

if (assembly) {
AssemblyEventData assembly_data;
memset (&assembly_data, 0, sizeof (assembly_data));
if (get_assembly_event_data (assembly, &assembly_data)) {
FireEtwAssemblyUnload_V1 (
assembly_data.assembly_id,
Expand Down Expand Up @@ -5473,6 +5479,7 @@ mono_profiler_module_loaded (

if (image) {
ModuleEventData module_data;
memset (&module_data, 0, sizeof (module_data));
if (get_module_event_data (image, &module_data))
module_path = (const ep_char8_t *)module_data.module_il_path;
module_guid = (const ep_char8_t *)mono_image_get_guid (image);
Expand Down Expand Up @@ -5524,6 +5531,7 @@ mono_profiler_module_unloaded (

if (image) {
ModuleEventData module_data;
memset (&module_data, 0, sizeof (module_data));
if (get_module_event_data (image, &module_data))
module_path = (const ep_char8_t *)module_data.module_il_path;
module_guid = (const ep_char8_t *)mono_image_get_guid (image);
Expand Down

0 comments on commit dbda62f

Please sign in to comment.