Skip to content

Ensure flags stored to raw relo record is 16 bits - #17982

Merged
jdmpapin merged 1 commit into
eclipse-openj9:masterfrom
dsouzai:fixReloFlags
Aug 22, 2023
Merged

Ensure flags stored to raw relo record is 16 bits#17982
jdmpapin merged 1 commit into
eclipse-openj9:masterfrom
dsouzai:fixReloFlags

Conversation

@dsouzai

@dsouzai dsouzai commented Aug 18, 2023

Copy link
Copy Markdown
Contributor

The _flags field of the TR_RelocationRecordBinaryTemplate struct is 16 bits wide. This was to ensure that the relocation infrastructure could store more than 4 bits of Relocation Flags (the other 4 bits are reserved for the Cross Platform Flags).

The code in TR_RelocationRecord::setReloFlags did some validation to ensure that the bits did not overlap; however, it did so using a uint8_t which could lose some bits due to a shift. This PR fixes this by ensuring a uint16_t is used.

This PR also changes how the flags are set; existing flags in the raw relocation record are now preserved.

@dsouzai

dsouzai commented Aug 18, 2023

Copy link
Copy Markdown
Contributor Author

@jdmpapin could you please review?

@jdmpapin

Copy link
Copy Markdown
Contributor

existing flags in the raw relocation record are now preserved.

The main change in this regard seems to be that setReloFlags() used to preserve only the "cross-platform" flags, but now it preserves all of them. I think it would be good for the commit message to mention the reason for this part of the change, e.g. maybe callers have been (incorrectly) expecting it to work that way?

@dsouzai

dsouzai commented Aug 18, 2023

Copy link
Copy Markdown
Contributor Author

I think it would be good for the commit message to mention the reason for this part of the change, e.g. maybe callers have been (incorrectly) expecting it to work that way?

Yeah I can update the commit message. As far as I can tell, nothing really depends on the relo flags not being preserved; however, because setReloFlags and setFlags were not consistent, I figured it's better to just make them consistent just to strengthen the conceptual integrity.

The _flags field of the TR_RelocationRecordBinaryTemplate struct is 16
bits wide. This was to ensure that the relocation infrastructure could
store more than 4 bits of Relocation Flags (the other 4 bits are
reserved for the Cross Platform Flags).

The code in TR_RelocationRecord::setReloFlags did some validation to
ensure that the bits did not overlap; however, it did so using a uint8_t
which could lose some bits due to a shift. This commit fixes this by
ensuring a uint16_t is used.

This commit also changes how the flags are set; existing flags in the
raw relocation record are now preserved. Prior to this change, setFlags
preserved the Cross Platform Flags but setReloFlags did not preserve the
Relo Flags. Nothing currently depends on this behaviour. Therefore, to
strengthen the conceptual integrity of these APIs, this commit makes the
behaviour of both setFlags and setReloFlags consistent.

Signed-off-by: Irwin D'Souza <dsouzai.gh@gmail.com>
@dsouzai

dsouzai commented Aug 18, 2023

Copy link
Copy Markdown
Contributor Author

Updated commit message.

@jdmpapin jdmpapin self-assigned this Aug 18, 2023
@jdmpapin

Copy link
Copy Markdown
Contributor

Jenkins test sanity.functional+aot all jdk17

@dsouzai

dsouzai commented Aug 18, 2023

Copy link
Copy Markdown
Contributor Author

Build failures due to #17527 (review)

@dsouzai dsouzai added the bug label Aug 18, 2023
@babsingh

Copy link
Copy Markdown
Contributor

#17986 should fix the build errors. I will relaunch the PR builds once #17986 is merged.

@dsouzai

dsouzai commented Aug 18, 2023

Copy link
Copy Markdown
Contributor Author

Realized that this PR actually does fix a bug (introduced by #17621), namely that the needsFullSizeRuntimeAssumption and methodTracingEnabled flags do get lost in the shift; added the bug label.

@babsingh

Copy link
Copy Markdown
Contributor

Relaunching PR builds since #17986 has been merged:

Jenkins test sanity.functional+aot all jdk17

@dsouzai

dsouzai commented Aug 21, 2023

Copy link
Copy Markdown
Contributor Author

x86 failure is due to an infra issue:

 Cannot contact ub16x64j91: java.lang.InterruptedException

aix failure is due to #17396:

[2023-08-19T01:20:06.457Z]  [ERR] Exception in thread "main" java.awt.AWTError: Can't connect to X11 window server using 'unix:0' as the value of the DISPLAY variable.
[2023-08-19T01:20:06.457Z]  [ERR] 	at java.desktop/sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
[2023-08-19T01:20:06.457Z]  [ERR] 	at java.desktop/sun.awt.X11GraphicsEnvironment$1.run(X11GraphicsEnvironment.java:105)

@jdmpapin

Copy link
Copy Markdown
Contributor

Jenkins test sanity+aot xlinux,aix jdk17

@dsouzai

dsouzai commented Aug 21, 2023

Copy link
Copy Markdown
Contributor Author

Jenkins test sanity.functional+aot xlinux,aix jdk17

@dsouzai

dsouzai commented Aug 22, 2023

Copy link
Copy Markdown
Contributor Author

aix failure due to the same issue

[2023-08-21T22:57:02.933Z]  [OUT] fontmanger LIB: libfontmanager.so
[2023-08-21T22:57:02.933Z]  [ERR] Exception in thread "main" java.awt.AWTError: Can't connect to X11 window server using 'unix:0' as the value of the DISPLAY variable.
[2023-08-21T22:57:02.933Z]  [ERR] 	at java.desktop/sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)

I've always had the suspicion, but now I'm starting to really think that issue is related to AOT and not infra. At any rate, this PR should be good for merging.

@jdmpapin
jdmpapin merged commit 34bcfd4 into eclipse-openj9:master Aug 22, 2023
@dsouzai
dsouzai deleted the fixReloFlags branch April 3, 2024 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants