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

Improve robustness of checking tags of allocated memory blocks #4191

Merged
merged 1 commit into from
Jan 8, 2019
Merged
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2010, 2014 IBM Corp. and others
* Copyright (c) 2010, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
Expand Down Expand Up @@ -72,9 +72,8 @@ public class J9MemTagHelper
*/
public static IDATA j9mem_check_tags(VoidPointer memoryPointer, long headerEyecatcher, long footerEyecatcher) throws J9MemTagCheckError
{
J9MemTagPointer headerTagAddress, footerTagAddress = J9MemTagPointer.NULL;

headerTagAddress = j9mem_get_header_tag(memoryPointer);
J9MemTagPointer headerTagAddress = j9mem_get_header_tag(memoryPointer);
J9MemTagPointer footerTagAddress = J9MemTagPointer.NULL;

try {
footerTagAddress = j9mem_get_footer_tag(headerTagAddress);
Expand Down Expand Up @@ -266,8 +265,9 @@ public static VoidPointer j9mem_get_footer_padding(J9MemTagPointer headerEyeCatc

public static UDATA ROUNDED_FOOTER_OFFSET(UDATA number)
{
UDATA a = (number.add(ROUNDING_GRANULARITY - 1)).add(J9MemTag.SIZEOF);
UDATA b = new UDATA(ROUNDING_GRANULARITY - 1).bitNot();
UDATA mask = new UDATA(ROUNDING_GRANULARITY - 1);
UDATA a = mask.add(number).add(J9MemTag.SIZEOF);
UDATA b = mask.bitNot();
return a.bitAnd(b);
}

Expand All @@ -294,7 +294,7 @@ public J9MemTagCheckError(J9MemTagPointer memTag,

public J9MemTagPointer getMemTag()
{
return memTag;
return memTag;
}
}
}