Skip to content

Conversation

@sendaoYan
Copy link
Member

@sendaoYan sendaoYan commented Dec 12, 2024

Hi all,
This PR fix file src/java.desktop/unix/native/libawt/awt/awt_LoadLibrary.c reported compile warning "ignoring return value of function" by clang17, which add check the return value of realpath function. Risk is low.


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-8346059: [ASAN] awt_LoadLibrary.c reported compile warning ignoring return value of function by clang17 (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 22701

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 12, 2024

👋 Welcome back syan! 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 Dec 12, 2024

@sendaoYan 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:

8346059: [ASAN] awt_LoadLibrary.c reported compile warning ignoring return value of function by clang17

Reviewed-by: ihse

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 16 new commits pushed to 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 added the rfr Pull request is ready for review label Dec 12, 2024
@openjdk
Copy link

openjdk bot commented Dec 12, 2024

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

  • client

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.

@openjdk openjdk bot added the client client-libs-dev@openjdk.org label Dec 12, 2024
@mlbridge
Copy link

mlbridge bot commented Dec 12, 2024

Webrevs

dladdr((void *)AWT_OnLoad, &dlinfo);
realpath((char *)dlinfo.dli_fname, buf);
if (realpath((char *)dlinfo.dli_fname, buf) == NULL) {
perror((char *)dlinfo.dli_fname);
Copy link
Member

@magicus magicus Dec 12, 2024

Choose a reason for hiding this comment

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

Having error handling is better than no error handling, but is perror the best we can do?

OTOH, maybe it doesn't matter as much. Something would be very, very broken if this were to fail.

Copy link
Contributor

Choose a reason for hiding this comment

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

I saw this in another bug report too from the same submitter.
I don't know that I want to encourage this as a pattern, except in debug builds. better might be to just copy dlinfo.dli_fname into buf ..

Copy link
Member Author

Choose a reason for hiding this comment

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

perror will print the given message accrording the previous errno info to stderr, so this change will not change the original behaviour.

Copy link
Member Author

@sendaoYan sendaoYan Dec 13, 2024

Choose a reason for hiding this comment

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

Hi @prrace,

I saw this in another bug report too from the same submitter.

I did create 3 clang17 compile waring issues, the compile warings occur in different files, and maybe use should different solutions to solve the issue, so I create the separate issues.

Copy link
Member Author

Choose a reason for hiding this comment

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

better might be to just copy dlinfo.dli_fname into buf

"Something would be very, very broken if this were to fail.", So I think perror maybe better, it will print which file and the reason get realpath fail.

Copy link
Member

Choose a reason for hiding this comment

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

Should I combine 3 similar issues(JDK-8346104/JDK-8346103/JDK-8346059) to 1 issue

I personally would probably have started out by making a single issue for these, since they all try to address the same new warning in clang, and are all in client code, and only split it up later if reviewers had requested it. But since you have created separate issues, I suggest you do not change things now. Also, the other two I believe need a more serious response; a write to a pipe has a somewhat more realistic chance at failure than this filename lookup.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry for the confuse. I mean this PR change nothing except it will print a message to stderr when realpath return NULL. Thanks magicus.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why did you integrate this ?
It did not yet have my approval even though I was clearly reviewing it.
Nor did it have the required 2nd reviewer, in fact did it not have ANY reviewer from the client team which is responsible for this code.

Copy link
Member Author

@sendaoYan sendaoYan Dec 18, 2024

Choose a reason for hiding this comment

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

Hi @prrace , sorry for the rash integrated. I can backout or redo this change quickly if it's necessary. If I should redo or backport this PR, please let me known.

I will pay more attention for the future PRs.

Apologize for the rash integrated again.

Copy link
Member

Choose a reason for hiding this comment

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

@prrace I don't think it is reasonable for you to blame @sendaoYan for integrating. He had a review from a Reviewer, and he waited 24 hours after that before integrating. The general JDK rule is that one review is enough; Hotspot as a special case requires two. Your comment did not say that you wanted to review it further, nor did you clearly request any changes, just a vague idea of replacing realpath with a strcpy (which seems like much more risky, and potentially incorrect, change!)

The responsibility for this PR is mine. I had reviewed and approved the PR. I did consider if I should increase the number of reviewers and state that a client team reviewer was also needed, but decided against it. That was my decision as a reviewer. The PR was clearly unproblematic. It added some extra logging in case something gets terribly wrong. Without this fix, AWT would just break without any indication whatsoever if something did go wrong with realpath. With this fix, this unlikely problem will at least get some indication. I did not think this needed confirmation from the client team as well.

Copy link
Member

@magicus magicus left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Dec 12, 2024
@prrace
Copy link
Contributor

prrace commented Dec 12, 2024

jtreg tests(include tier1/2/3) on linux-x64 with release build
jtreg tests(include tier1/2/3) on linux-x64 with fastdebug build
jtreg tests(include tier1/2/3) on linux-aarch64 with release build
jtreg tests(include tier1/2/3) on linux-aarch64 with fastdebug build

That was entirely a waste of time and hasn't proved anything.

If you examine the content of those tiers you will not find even a single test that loads AWT !

Try running the jdk_desktop group instead.

@sendaoYan
Copy link
Member Author

sendaoYan commented Dec 13, 2024

Try running the jdk_desktop group instead.

Thanks your advice. Mine meaning was verify this change will not cause new failures, since it will not change behaviour in theory.

I have run all the jtreg tests except test/hotspot/jtreg/vmTestbase/ and test/hotspot/jtreg/applications/, which has include jdk_desktop.

@sendaoYan
Copy link
Member Author

Compile warning of JDK-8346059 was introduced recently, Compile warnings of JDK-8346104/JDK-8346103 has exists for several years. So I want to deal with JDK-8346059 separately make other issues can be backported to jdk21u-dev or jdk17u-dev cleanly.

@magicus
Copy link
Member

magicus commented Dec 13, 2024

Thanks your advice. Mine meaning was verify this change will not cause new failures, since it will not change behaviour in theory.

Well, yes, but to prove that you do need to run tests that actually exercise the code.

@sendaoYan
Copy link
Member Author

Thanks all for the reviews.

/integrate

@openjdk
Copy link

openjdk bot commented Dec 13, 2024

Going to push as commit 367c304.
Since your change was applied there have been 19 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 Dec 13, 2024
@openjdk openjdk bot closed this Dec 13, 2024
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Dec 13, 2024
@openjdk
Copy link

openjdk bot commented Dec 13, 2024

@sendaoYan Pushed as commit 367c304.

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

@sendaoYan sendaoYan deleted the jbs8346059 branch December 13, 2024 08:35
@tstuefe
Copy link
Member

tstuefe commented Dec 18, 2024

Drive-By comment:

I think we should avoid perror, since its error message is localized. I would prefer these messages in English, not in whatever language the customer set up. If you really want to print a message, at least also print out the numerical value of errno.

See https://pubs.opengroup.org/onlinepubs/007904875/functions/perror.html

"The perror() function shall map the error number accessed through the symbol errno to a language-dependent error message"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

client client-libs-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

4 participants