Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8269882

stack-use-after-scope in NewObjectA

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b05
    • CPU:
      generic
    • OS:
      generic

      Backports

        Description

        Running tests (for example, jtreg:test/jdk/javax/imageio/plugins/bmp/Write3ByteBgrTest.java) with Address Sanitizer results in failures like this one:

        SUMMARY: AddressSanitizer: stack-use-after-scope /.../jdk/src/hotspot/share/prims/jni.cpp:972 in DTraceReturnProbeMark_NewObjectA::~DTraceReturnProbeMark_NewObjectA()

        In NewObjectA(), the return value of the function is passed to the probe-supporting macro by value instead of by reference:
          DT_RETURN_MARK(NewObjectA, jobject, (const jobject)obj);
        (notice 'const jobject' instead of 'const jobject&')
        Casting a variable to a non-reference type technically makes the resulting expression a prvalue, which then gets bound to a reference that is alive up until the end of the function. The prvalue is then touched in the destructor of DTraceReturnProbeMark_NewObjectA (a local class created by the DT_RETURN_MARK macro) and this is detected by Address Sanitizer as stack-use-after-scope when running certain tests.

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                dholmes David Holmes
                Reporter:
                vprovodin Vitaly Provodin
                Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: