RFR: 8170812: Metaspace corruption caused by incorrect memory size for MethodCounters
Kim Barrett
kim.barrett at oracle.com
Thu Apr 6 01:31:24 UTC 2017
> On Apr 5, 2017, at 11:13 AM, Andrew Haley <aph at redhat.com> wrote:
>
> If sizeof (MethodCounters) is not a multiple of wordSize, memory
> allocator metadata is corrupted, causing the VM to become unstable and
> eventually crash.
>
> The fix is very simple:
>
> diff -r 85b6ca9458ed src/share/vm/oops/methodCounters.hpp
> --- a/src/share/vm/oops/methodCounters.hpp Wed Mar 29 15:44:34 2017 +0000
> +++ b/src/share/vm/oops/methodCounters.hpp Wed Apr 05 15:42:18 2017 +0100
> @@ -116,7 +116,7 @@
>
> AOT_ONLY(Method* method() const { return _method; })
>
> - static int size() { return sizeof(MethodCounters) / wordSize; }
> + static int size() { return align_size_up(sizeof(MethodCounters), wordSize) / wordSize; }
>
> bool is_klass() const { return false; }
>
> This is very low risk because if the size is already a multiple of
> wordSize, this patch will have no effect. If the size is not a
> multiple of wordSize, this patch will prevent an inevitable crash.
>
> I've applied for a JDK9 fix request. I'll need a sponsor.
>
> Andrew.
It looks like it might require a fairly specific set of build options, but yikes!
Change looks good.
More information about the hotspot-dev
mailing list