Skip to content

Commit

Permalink
8333639: ubsan: cppVtables.cpp:81:55: runtime error: index 14 out of …
Browse files Browse the repository at this point in the history
…bounds for type 'long int [1]'

Backport-of: 0199fee431e0dccdd570b38595ea29c760dbed44
  • Loading branch information
MBaesken committed Aug 9, 2024
1 parent fd4ce63 commit 953846d
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/hotspot/share/cds/cppVtables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,17 @@

class CppVtableInfo {
intptr_t _vtable_size;
intptr_t _cloned_vtable[1];
intptr_t _cloned_vtable[1]; // Pseudo flexible array member.
static size_t cloned_vtable_offset() { return offset_of(CppVtableInfo, _cloned_vtable); }
public:
static int num_slots(int vtable_size) {
return 1 + vtable_size; // Need to add the space occupied by _vtable_size;
}
int vtable_size() { return int(uintx(_vtable_size)); }
void set_vtable_size(int n) { _vtable_size = intptr_t(n); }
intptr_t* cloned_vtable() { return &_cloned_vtable[0]; }
void zero() { memset(_cloned_vtable, 0, sizeof(intptr_t) * vtable_size()); }
// Using _cloned_vtable[i] for i > 0 causes undefined behavior. We use address calculation instead.
intptr_t* cloned_vtable() { return (intptr_t*)((char*)this + cloned_vtable_offset()); }
void zero() { memset(cloned_vtable(), 0, sizeof(intptr_t) * vtable_size()); }
// Returns the address of the next CppVtableInfo that can be placed immediately after this CppVtableInfo
static size_t byte_size(int vtable_size) {
CppVtableInfo i;
return pointer_delta(&i._cloned_vtable[vtable_size], &i, sizeof(u1));
return cloned_vtable_offset() + (sizeof(intptr_t) * vtable_size);
}
};

Expand Down

1 comment on commit 953846d

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.