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

i#4777: Fix uninitialized drmodtrack offset on Windows #4778

Merged
merged 2 commits into from
Mar 10, 2021
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
1 change: 1 addition & 0 deletions ext/drcovlib/drcovlib.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ typedef struct _drmodtrack_info_t {
uint index;
/**
* The offset of this segment from the beginning of this backing file.
* On Windows this field is always 0.
*/
uint64 offset;
} drmodtrack_info_t;
Expand Down
14 changes: 7 additions & 7 deletions ext/drcovlib/modules.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* ***************************************************************************
* Copyright (c) 2012-2019 Google, Inc. All rights reserved.
* Copyright (c) 2012-2021 Google, Inc. All rights reserved.
* ***************************************************************************/

/*
Expand Down Expand Up @@ -55,10 +55,8 @@ typedef struct _module_entry_t {
*/
module_data_t *data;
void *custom;
#ifndef WINDOWS
/* The file offset of the segment */
uint64 offset;
#endif
} module_entry_t;

typedef struct _module_table_t {
Expand Down Expand Up @@ -191,7 +189,9 @@ event_module_load(void *drcontext, const module_data_t *data, bool loaded)
if (module_load_cb != NULL)
entry->custom = module_load_cb(entry->data, 0);
drvector_append(&module_table.vector, entry);
#ifndef WINDOWS
#ifdef WINDOWS
entry->offset = 0;
#else
entry->offset = data->segments[0].offset;
uint j;
module_entry_t *sub_entry;
Expand Down Expand Up @@ -459,10 +459,10 @@ module_table_entry_print(module_entry_t *entry, char *buf, size_t size)
#endif
read_entry.path = full_path;
read_entry.custom = entry->custom;
#ifndef WINDOWS
// For unices we record the physical offset from the backing file.
/* For unices we record the physical offset from the backing file
*(always 0 on Windows).
*/
read_entry.offset = entry->offset;
#endif
return module_read_entry_print(&read_entry, entry->id, buf, size);
}

Expand Down