Skip to content

8266172: -Wstringop-overflow happens in vmError.cpp #3789

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

Closed
wants to merge 1 commit into from

Conversation

YaSuenag
Copy link
Member

@YaSuenag YaSuenag commented Apr 29, 2021

We can see following compiler warnings in vmError.cpp on GCC 11.

In function 'void crash_with_segfault()',
    inlined from 'static void VMError::controlled_crash(int)' at /home/ysuenaga/github-forked/jdk/src/hotspot/share/utilities/vmError.cpp:1804:33:
/home/ysuenaga/github-forked/jdk/src/hotspot/share/utilities/vmError.cpp:1774:15: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
 1774 |   *crash_addr = 'X';
      |   ~~~~~~~~~~~~^~~~~

According to GCC documents, -Wstringop-overflow is meaningful only for functions that operate on character arrays, and also this point is correct because it is a test code for the crash on non-null address. So we can replace to use int.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8266172: -Wstringop-overflow happens in vmError.cpp

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/3789/head:pull/3789
$ git checkout pull/3789

Update a local copy of the PR:
$ git checkout pull/3789
$ git pull https://git.openjdk.java.net/jdk pull/3789/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 3789

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/3789.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 29, 2021

👋 Welcome back ysuenaga! 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 Apr 29, 2021

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

  • hotspot

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 hotspot hotspot-dev@openjdk.org label Apr 29, 2021
@YaSuenag YaSuenag marked this pull request as ready for review April 29, 2021 13:05
@openjdk openjdk bot added the rfr Pull request is ready for review label Apr 29, 2021
@mlbridge
Copy link

mlbridge bot commented Apr 29, 2021

Webrevs

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.

I'm not sure whether to disable the warning via pragma, as this is a bogus warning, or whether to side-step by changing to int* as you have.

As long as we still crash "correctly" I suppose this is okay.

Thanks,
David

@openjdk
Copy link

openjdk bot commented Apr 29, 2021

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

8266172: -Wstringop-overflow happens in vmError.cpp

Reviewed-by: dholmes, stuefe

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 101 new commits pushed to the master branch:

  • 7835cdb: 8265915: adjust state_unloading_cycle compuation order in nmethod::is_unloading
  • 20ad428: 8180568: Refactor javax/crypto shell tests to plain java tests
  • 138d573: 8262392: Update Mesa 3-D Headers to version 21.0.3
  • 9de62a4: 8266505: Cleanup LibraryCallKit::make_unsafe_address()
  • 1885c83: 8266504: Remove leftovers from BarrierSetAssemblerC1
  • 6018336: 8259316: [REDO] C1/C2 compiler support for blackholes
  • f07bb2f: 8250766: javadoc adds redundant spaces when @see program element is wrapped
  • 61bb6ec: 8266453: Shenandoah: Disable write protections before patching nmethod in nmethod_barrier on MacOSX/AArch64
  • a05e8e2: 8266497: Remove unnecessary EMCP liveness indication
  • 6ba911d: 8266498: Make debug ps() call print_stack
  • ... and 91 more: https://git.openjdk.java.net/jdk/compare/56cde70da271ef5437d5544b3bd9ba26e4148af1...master

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 ready Pull request is ready to be integrated label Apr 29, 2021
@YaSuenag
Copy link
Member Author

YaSuenag commented May 6, 2021

Ping: Could you review this PR? I need one more reviewer to push. We still see this warning with GCC 11.1.

Copy link
Member

@tstuefe tstuefe left a comment

Choose a reason for hiding this comment

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

I'm fine with this patch.

nit: does the C++ styleguide require C++ casts now? I don't remember seeing anything. I dislike the verbosity of these casts.

Cheers, Thomas

@YaSuenag
Copy link
Member Author

YaSuenag commented May 6, 2021

Thanks @tstuefe for the review!

does the C++ styleguide require C++ casts now? I don't remember seeing anything.

Me too, but I found 745 entries when I grep'ed HotSpot source with '_cast<', and also HotSpot is starting to use C++ 14 since JEP 347. So I decided to use C++ casts at here.

@YaSuenag
Copy link
Member Author

YaSuenag commented May 7, 2021

/integrate

@openjdk openjdk bot closed this May 7, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels May 7, 2021
@openjdk
Copy link

openjdk bot commented May 7, 2021

@YaSuenag Since your change was applied there have been 121 commits pushed to the master branch:

  • 43ad24f: 8265465: jcmd VM.cds should keep already dumped archive when exception happens
  • 66191ff: 8266193: BasicJMapTest does not include testHistoParallel methods
  • 36e5ad6: 8263236: runtime/os/TestTracePageSizes.java fails on old kernels
  • 0ca86da: 8266002: vmTestbase/nsk/jvmti/ClassPrepare/classprep001 should skip events for unexpected classes
  • 52f1db6: 8262002: java/lang/instrument/VerifyLocalVariableTableOnRetransformTest.sh failed with "TestCaseScaffoldException: DummyClassWithLVT did not match .class file"
  • 04f7112: 8266293: Key protection using PBEWithMD5AndDES fails with "java.security.InvalidAlgorithmParameterException: Salt must be 8 bytes long"
  • a90b33a: 8266573: Make sure blackholes are tagged for all JVMCI paths
  • 2dcbedf: 8266044: Nested class summary should show kind of class or interface
  • e840597: 8266460: java.io tests fail on null stream with upgraded jtreg/TestNG
  • fcedfc8: 8266579: Update test/jdk/java/lang/ProcessHandle/PermissionTest.java & test/jdk/java/sql/testng/util/TestPolicy.java
  • ... and 111 more: https://git.openjdk.java.net/jdk/compare/56cde70da271ef5437d5544b3bd9ba26e4148af1...master

Your commit was automatically rebased without conflicts.

Pushed as commit c97f56c.

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

@YaSuenag YaSuenag deleted the JDK-8266172 branch May 7, 2021 03:59
@mlbridge
Copy link

mlbridge bot commented May 14, 2021

Mailing list message from David Holmes on hotspot-dev:

On 6/05/2021 5:17 pm, Thomas Stuefe wrote:

On Thu, 29 Apr 2021 07:26:05 GMT, Yasumasa Suenaga <ysuenaga at openjdk.org> wrote:

We can see following compiler warnings in vmError.cpp on GCC 11.

In function 'void crash_with_segfault()',
inlined from 'static void VMError::controlled_crash(int)' at /home/ysuenaga/github-forked/jdk/src/hotspot/share/utilities/vmError.cpp:1804:33:

I'm fine with this patch.

nit: does the C++ styleguide require C++ casts now? I don't remember seeing anything. I dislike the verbosity of these casts.

The hotspot style guide says nothing about casts, but internally we've
been switching to using C++ casts and avoid old C-style casts.

Cheers,
David

1 similar comment
@mlbridge
Copy link

mlbridge bot commented May 14, 2021

Mailing list message from David Holmes on hotspot-dev:

On 6/05/2021 5:17 pm, Thomas Stuefe wrote:

On Thu, 29 Apr 2021 07:26:05 GMT, Yasumasa Suenaga <ysuenaga at openjdk.org> wrote:

We can see following compiler warnings in vmError.cpp on GCC 11.

In function 'void crash_with_segfault()',
inlined from 'static void VMError::controlled_crash(int)' at /home/ysuenaga/github-forked/jdk/src/hotspot/share/utilities/vmError.cpp:1804:33:

I'm fine with this patch.

nit: does the C++ styleguide require C++ casts now? I don't remember seeing anything. I dislike the verbosity of these casts.

The hotspot style guide says nothing about casts, but internally we've
been switching to using C++ casts and avoid old C-style casts.

Cheers,
David

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot hotspot-dev@openjdk.org integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

3 participants