[Bug 209599] SIGSEGV in regression test suite on java/openjdk8

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Thu May 19 16:07:59 UTC 2016


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=209599

--- Comment #9 from Andrew Smith <iamasmith.home at gmail.com> ---
Went at this form the other end as I had visibility of the native code.

Examining the stack from earlier we have the use of the load method to look at.

Stack: [0x00007fffdf1f1000,0x00007fffdf2f1000],  sp=0x00007fffdf2f0860,  free
space=1022k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V  [libjvm.so+0x8d8d0a]  JVM_handle_bsd_signal+0x125c4a
j  sun.misc.Unsafe.getByte(J)B+0
j  java.nio.MappedByteBuffer.load()Ljava/nio/MappedByteBuffer;+85
j  Truncate$2.call()Ljava/lang/Void;+4
j  Truncate$2.call()Ljava/lang/Object;+1
j  Truncate$3.run()V+4
j  java.lang.Thread.run()V+11
v  ~StubRoutines::call_stub
V  [libjvm.so+0x59d83b]  AsyncGetCallTrace+0xcab7b
V  [libjvm.so+0x59c283]  AsyncGetCallTrace+0xc95c3
V  [libjvm.so+0x59c4bc]  AsyncGetCallTrace+0xc97fc
V  [libjvm.so+0x608c3e]  JVM_StartThread+0x36e
V  [libjvm.so+0x8b1600]  JVM_handle_bsd_signal+0xfe540
V  [libjvm.so+0x7ad3af]  JVM_FindSignal+0x19a4ff
C  [libthr.so.3+0x8855]  operator->+0x805
C  0x0000000000000000

    public final MappedByteBuffer load() {
        checkMapped();
        if ((address == 0) || (capacity() == 0))
            return this;
        long offset = mappingOffset();
        long length = mappingLength(offset);
        load0(mappingAddress(offset), length);

        // Read a byte from each page to bring it into memory. A checksum
        // is computed as we go along to prevent the compiler from otherwise
        // considering the loop as dead code.
        Unsafe unsafe = Unsafe.getUnsafe();
        int ps = Bits.pageSize();
        int count = Bits.pageCount(length);
        long a = mappingAddress(offset);
        byte x = 0;
        for (int i=0; i<count; i++) {
            x ^= unsafe.getByte(a);
            a += ps;
        }
        if (unused != 0)
            unused = x;

        return this;
    }

Unsafe, it seems is used to demand page the file in.

Looking at other unit tests we can see .load works OK, however, in this test
the file is truncated an then we attempt to demand page it in (this works based
on the length known by the MappedByteBuffer and here's where it fails.


        try {
            fc.truncate(TRUNCATED_FILE_SIZE);
            truncated = true;
        } catch (IOException ioe) {
            // probably on Windows where a file cannot be truncated when
            // there is a file mapping.
            truncated = false;
        }
        if (truncated) {
            // Test 1: access region that is no longer accessible
            execute(new Callable<Void>() {
                public Void call() {
                    mbb.get((int)TRUNCATED_FILE_SIZE + 1);
                    mbb.put((int)TRUNCATED_FILE_SIZE + 2, (byte)123);
                    return null;
                }
            });
            // Test 2: load buffer into memory
            execute(new Callable<Void>() {
                public Void call() throws IOException {
                    mbb.load();
                    return null;
                }
            });
        }
        fc.close();
    }

    // Runs the given task in its own thread. If operating correcting the
    // the thread will terminate with an InternalError as the mapped buffer
    // is inaccessible.
    static void execute(final Callable<?> c) {
        Runnable r = new Runnable() {
            public void run() {
                try {
                    Object ignore = c.call();
                } catch (Exception ignore) {
                }
            }
        };

Noting what it mentions in the execute wrapper.. there is an expectation that
InternalError is raised but we are receiving a SIGSEGV.

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-java mailing list