Skip to content

Commit

Permalink
8346881: [ubsan] logSelection.cpp:154:24 / logSelectionList.cpp:72:94…
Browse files Browse the repository at this point in the history
… : runtime error: applying non-zero offset 1 to null pointer

Reviewed-by: clanger, mdoerr, dholmes, syan, amitkumar
  • Loading branch information
MBaesken committed Jan 7, 2025
1 parent 08debd3 commit 0a81676
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/hotspot/share/logging/logDecorators.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -100,7 +100,9 @@ bool LogDecorators::parse(const char* decorator_args, outputStream* errstream) {
break;
}
tmp_decorators |= mask(d);
token = comma_pos + 1;
if (comma_pos != nullptr) {
token = comma_pos + 1;
}
} while (comma_pos != nullptr);
os::free(args_copy);
if (result) {
Expand Down
6 changes: 4 additions & 2 deletions src/hotspot/share/logging/logSelection.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -151,7 +151,9 @@ static LogSelection parse_internal(char *str, outputStream* errstream) {
return LogSelection::Invalid;
}
tags[ntags++] = tag;
cur_tag = plus_pos + 1;
if (plus_pos != nullptr) {
cur_tag = plus_pos + 1;
}
} while (plus_pos != nullptr);

for (size_t i = 0; i < ntags; i++) {
Expand Down
8 changes: 6 additions & 2 deletions src/hotspot/share/logging/logSelectionList.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -69,7 +69,7 @@ bool LogSelectionList::parse(const char* str, outputStream* errstream) {
}
char* copy = os::strdup_check_oom(str, mtLogging);
// Split string on commas
for (char *comma_pos = copy, *cur = copy; success && comma_pos != nullptr; cur = comma_pos + 1) {
for (char *comma_pos = copy, *cur = copy; success; cur = comma_pos + 1) {
if (_nselections == MaxSelections) {
if (errstream != nullptr) {
errstream->print_cr("Can not have more than " SIZE_FORMAT " log selections in a single configuration.",
Expand All @@ -90,6 +90,10 @@ bool LogSelectionList::parse(const char* str, outputStream* errstream) {
break;
}
_selections[_nselections++] = selection;

if (comma_pos == nullptr) {
break;
}
}

os::free(copy);
Expand Down

5 comments on commit 0a81676

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@MBaesken
Copy link
Member Author

Choose a reason for hiding this comment

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

/backport jdk24u

@openjdk
Copy link

@openjdk openjdk bot commented on 0a81676 Feb 7, 2025

Choose a reason for hiding this comment

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

@MBaesken the backport was successfully created on the branch backport-MBaesken-0a81676f-master in my personal fork of openjdk/jdk24u. To create a pull request with this backport targeting openjdk/jdk24u:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 0a81676f from the openjdk/jdk repository.

The commit being backported was authored by Matthias Baesken on 7 Jan 2025 and was reviewed by Christoph Langer, Martin Doerr, David Holmes, SendaoYan and Amit Kumar.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk24u:

$ git fetch https://github.com/openjdk-bots/jdk24u.git backport-MBaesken-0a81676f-master:backport-MBaesken-0a81676f-master
$ git checkout backport-MBaesken-0a81676f-master
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk24u.git backport-MBaesken-0a81676f-master

@MBaesken
Copy link
Member Author

Choose a reason for hiding this comment

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

/backport jdk21u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 0a81676 Feb 11, 2025

Choose a reason for hiding this comment

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

@MBaesken Could not automatically backport 0a81676f to openjdk/jdk21u-dev due to conflicts in the following files:

  • src/hotspot/share/logging/logDecorators.cpp
  • src/hotspot/share/logging/logSelection.cpp
  • src/hotspot/share/logging/logSelectionList.cpp

Please fetch the appropriate branch/commit and manually resolve these conflicts by using the following commands in your personal fork of openjdk/jdk21u-dev. Note: these commands are just some suggestions and you can use other equivalent commands you know.

# Fetch the up-to-date version of the target branch
$ git fetch --no-tags https://git.openjdk.org/jdk21u-dev.git master:master

# Check out the target branch and create your own branch to backport
$ git checkout master
$ git checkout -b backport-MBaesken-0a81676f-master

# Fetch the commit you want to backport
$ git fetch --no-tags https://git.openjdk.org/jdk.git 0a81676fae3b25117dd2289a734193bcbee822de

# Backport the commit
$ git cherry-pick --no-commit 0a81676fae3b25117dd2289a734193bcbee822de
# Resolve conflicts now

# Commit the files you have modified
$ git add files/with/resolved/conflicts
$ git commit -m 'Backport 0a81676fae3b25117dd2289a734193bcbee822de'

Once you have resolved the conflicts as explained above continue with creating a pull request towards the openjdk/jdk21u-dev with the title Backport 0a81676fae3b25117dd2289a734193bcbee822de.

Below you can find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 0a81676f from the openjdk/jdk repository.

The commit being backported was authored by Matthias Baesken on 7 Jan 2025 and was reviewed by Christoph Langer, Martin Doerr, David Holmes, SendaoYan and Amit Kumar.

Thanks!

Please sign in to comment.