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

Client UUID appears truncated in verbose log #9962

Closed
mpirvu opened this issue Jun 20, 2020 · 2 comments
Closed

Client UUID appears truncated in verbose log #9962

mpirvu opened this issue Jun 20, 2020 · 2 comments
Labels
comp:jitserver Artifacts related to JIT-as-a-Service project

Comments

@mpirvu
Copy link
Contributor

mpirvu commented Jun 20, 2020

Under -Xjit:verbose={JITServer} the client prints its UUID in the verbose log, but it appears truncated:
#JITServer: Identifier for current client JVM: 3663742628
while it should have been like this:
#JITServer: Identifier for current client JVM: 9388384503642212004

The line that prints the UUID is like this:

         TR_VerboseLog::writeLineLocked(TR_Vlog_JITServer, "Identifier for current client JVM: %" OMR_PRIu64 "\n",
               compInfo->getPersistentInfo()->getClientUID());

It seems that OMR_PRIu64 does not play nice with the verbose log. I replaced that with PRIu64 and got the same bad result. "%llu" on the other hand prints the correct value.
Note that if I use fprintf instead of TR_VerboseLog::writeLineLocked then everything is fine, so it's just the combination of verbose log and OMR_PRIu64 that misbehaves.

@mpirvu mpirvu added the comp:jitserver Artifacts related to JIT-as-a-Service project label Jun 20, 2020
@dmitry-ten
Copy link
Contributor

dmitry-ten commented Jul 20, 2020

The reason it doesn't work correctly is due to verbose log using a custom print function implemented in OMR and it not being compatible with PRI format specifiers.
OMR_PRIu64 is equivalent to PRIu64 macro, which converts to %lu on a Ubuntu 64-bit machine.
The standard library print functions handle this format specifier correctly, i.e. given a 64-bit value, print out all the bits.
However, the OMR implementation (in omrstr.c) only considers the value to be 64-bit, if the %llu specifier is used, as can be seen here:
https://github.com/eclipse/omr/blob/465d74a8668dd1ec3a726944a6ffd53d3548cf23/port/common/omrstr.c#L660-L667

I verified that if we change line 665 to always assign J9FTYPE_U64 type, then the correct client id is printed.

Fixing how printing works in OMR, for all platforms, seems like a pretty difficult task. For now, I'll just explicitly use %llu specifier instead of OMR_PRIu64.

dmitry-ten added a commit to dmitry-ten/openj9 that referenced this issue Jul 21, 2020
On the client-side, the uuid appeared truncated
to 32 bits, as described in eclipse-openj9#9962.
This is due to custom OMR print function and `PRI`
format specifiers not interacting correctly.
Fix it by using `%llu` specifier instead of `%OMR_PRIu64`.

Signed-off-by: Dmitry Ten <Dmitry.Ten@ibm.com>
@mpirvu
Copy link
Contributor Author

mpirvu commented Aug 4, 2020

Resolved by #10209

@mpirvu mpirvu closed this as completed Aug 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:jitserver Artifacts related to JIT-as-a-Service project
Projects
None yet
Development

No branches or pull requests

2 participants