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

8346881: [ubsan] logSelection.cpp:154:24 / logSelectionList.cpp:72:94 : runtime error: applying non-zero offset 1 to null pointer #22903

Closed
wants to merge 3 commits into from

Conversation

MBaesken
Copy link
Member

@MBaesken MBaesken commented Jan 2, 2025

When running jtreg tests on macOS aarch64 with ubsanized binaries, the following error is reported :

jdk/src/hotspot/share/logging/logSelection.cpp:154:24: runtime error: applying non-zero offset 1 to null pointer
UndefinedBehaviorSanitizer:DEADLYSIGNAL
UndefinedBehaviorSanitizer: nested bug in the same thread, aborting.

(XCode 13.1 was used)

This can be seen e.g. in these jdk jtreg tests :
jdk/internal/misc/CDS/ArchivedEnumTest.java
jdk/jfr/event/gc/collection/TestGCGarbageCollectionEvent.java
jdk/jfr/startupargs/TestDumpOnExit.java

There is another issue observed here (also when running on macOS aarch64) , seems this happens in the for loop when incrementing comma_pos
" for (char *comma_pos = copy, *cur = copy; success && comma_pos != nullptr; cur = comma_pos + 1) { ..."

src/hotspot/share/logging/logSelectionList.cpp:72:94: runtime error: applying non-zero offset 1 to null pointer
UndefinedBehaviorSanitizer:DEADLYSIGNAL
UndefinedBehaviorSanitizer: nested bug in the same thread, aborting.

Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8346881: [ubsan] logSelection.cpp:154:24 / logSelectionList.cpp:72:94 : runtime error: applying non-zero offset 1 to null pointer (Bug - P4)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/22903/head:pull/22903
$ git checkout pull/22903

Update a local copy of the PR:
$ git checkout pull/22903
$ git pull https://git.openjdk.org/jdk.git pull/22903/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 22903

View PR using the GUI difftool:
$ git pr show -t 22903

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/22903.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 2, 2025

👋 Welcome back mbaesken! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Jan 2, 2025

@MBaesken This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8346881: [ubsan] logSelection.cpp:154:24  / logSelectionList.cpp:72:94 : runtime error: applying non-zero offset 1 to null pointer

Reviewed-by: clanger, mdoerr, dholmes, syan, amitkumar

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 6 new commits pushed to the master branch:

  • f1d85ab: 8346773: Fix unmatched brackets in some misc files
  • 9393897: 8346260: Test "javax/swing/JOptionPane/bug4174551.java" failed because the font size of message "Hi 24" is not set to 24 in Nimbus LookAndFeel
  • e98f412: 8346922: TestVectorReinterpret.java fails without the rvv extension on RISCV fastdebug VM
  • ca5390c: 8346924: TestVectorizationNegativeScale.java fails without the rvv extension on RISCV fastdebug VM
  • 07c9f71: 8346921: Remove unused arg in markWord::must_be_preserved
  • 84e6432: 8346288: WB_IsIntrinsicAvailable fails if called with wrong compilation level

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot changed the title JDK-8346881: [ubsan] logSelection.cpp:154:24 / logSelectionList.cpp:72:94 : runtime error: applying non-zero offset 1 to null pointer 8346881: [ubsan] logSelection.cpp:154:24 / logSelectionList.cpp:72:94 : runtime error: applying non-zero offset 1 to null pointer Jan 2, 2025
@openjdk openjdk bot added the rfr Pull request is ready for review label Jan 2, 2025
@openjdk
Copy link

openjdk bot commented Jan 2, 2025

@MBaesken The following label will be automatically applied to this pull request:

  • hotspot-runtime

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@mlbridge
Copy link

mlbridge bot commented Jan 2, 2025

Webrevs


if (comma_pos == nullptr) {
break;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this check is not necessary here since it is checked in the for loop condition already - or am I overlooking something?

Copy link
Member Author

Choose a reason for hiding this comment

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

Unfortunately we still run into the issue , even with the existing loop condition.
check the flowchart of the for loop
https://www.programiz.com/cpp-programming/for-loop
the update condition is done after the body ; then we run into the issue.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, right, I see. But in that case, we can/should remove the check for comma_pos != nullptr from the condition because we're explicitly doing it in the loop body then.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree, the check can be simplified .

@MBaesken
Copy link
Member Author

MBaesken commented Jan 2, 2025

Seems we have a similar one here, show by test runtime/MemberName/MemberNameLeak (macOS aarch64)

src/hotspot/share/logging/logDecorators.cpp:103:23: runtime error: applying non-zero offset 1 to null pointer

Should I address it here too ?

@RealCLanger
Copy link
Contributor

Seems we have a similar one here, show by test runtime/MemberName/MemberNameLeak (macOS aarch64)

src/hotspot/share/logging/logDecorators.cpp:103:23: runtime error: applying non-zero offset 1 to null pointer

Should I address it here too ?

yes, makes sense.

@MBaesken
Copy link
Member Author

MBaesken commented Jan 3, 2025

I adjusted logDecorators.cpp too .

Copy link
Contributor

@RealCLanger RealCLanger left a comment

Choose a reason for hiding this comment

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

I think for the sake of consistency, the loop in logSelectionList.cpp could be transformed into a do {} while(), like in the other two locations, but in any case, the change looks good to me as it is now.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jan 3, 2025
Copy link
Contributor

@TheRealMDoerr TheRealMDoerr left a comment

Choose a reason for hiding this comment

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

LGTM.

@MBaesken
Copy link
Member Author

MBaesken commented Jan 3, 2025

Thanks for the reviews !

Copy link
Member

@dholmes-ora dholmes-ora left a comment

Choose a reason for hiding this comment

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

LGTM2

Thanks

Copy link
Member

@sendaoYan sendaoYan left a comment

Choose a reason for hiding this comment

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

LGTM

@offamitkumar
Copy link
Member

I think for the sake of consistency, the loop in logSelectionList.cpp could be transformed into a do {} while(), like in the other two locations, but in any case, the change looks good to me as it is now.

I think for loop is better choice for this kind of occasion. Because in logDecorators.cpp :

  char* token = args_copy;
  char* comma_pos;

these two variables are doing no good by being in function scope. If it would have been a for loop then then would exist in the loop's scope only. As that's the case for comma_pos and cur here:

for (char *comma_pos = copy, *cur = copy; success; cur = comma_pos + 1) {

It might not be a big deal but still I find later one appropriate :-)

@MBaesken
Copy link
Member Author

MBaesken commented Jan 7, 2025

Thanks for the reviews !

/integrate

@openjdk
Copy link

openjdk bot commented Jan 7, 2025

Going to push as commit 0a81676.
Since your change was applied there have been 20 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jan 7, 2025
@openjdk openjdk bot closed this Jan 7, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jan 7, 2025
@openjdk
Copy link

openjdk bot commented Jan 7, 2025

@MBaesken Pushed as commit 0a81676.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-runtime [email protected] integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

6 participants