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

Segmentation fault in JVM (easily reproducible)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 9
    • 7u60, 8, 9
    • hotspot
    • b20
    • x86
    • os_x

        FULL PRODUCT VERSION :
        java version "1.7.0_60"
        Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
        Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)

        FULL OS VERSION :
        OSX 10.9.2
        OSX 10.6.8
        Ubuntu 14.04
        Windows 7

        A DESCRIPTION OF THE PROBLEM :
        I have some simple code that causes a segmentation fault.
         
        Running in the Eclipse debugger or with the interpreter (using -Xint option) prevents the segfault from occurring.

        I made a stack overflow post here:
        http://stackoverflow.com/questions/24101142/java-fatal-error-sigsegv
        Several commenters, on several different machines, were able to reproduce the error.

        My code involves cacheing some computations in logarithmic scale. Specifically, given log(X),log(Y),..., I have a small class that computes log(X+Y+...). And then I cache the result in a HashMap. My code is <100 lines long, and only uses classes from java.util (no native libraries).

        THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: No

        THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Yes

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Run the small code I have attached.

        Sometimes I have to run the code a couple of times for the error to occur, but it happens more often than not.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        Expected: print out a bunch of numbers and terminate

        Actual: print out a bunch of numbers and get a segmentation fault at some point.
        ERROR MESSAGES/STACK TRACES THAT OCCUR :
        #
        # A fatal error has been detected by the Java Runtime Environment:
        #
        # SIGSEGV (0xb) at pc=0x000000010fda8262, pid=21419, tid=18435
        #
        # JRE version: Java(TM) SE Runtime Environment (7.0_60-b19) (build 1.7.0_60-b19)
        # Java VM: Java HotSpot(TM) 64-Bit Server VM (24.60-b09 mixed mode bsd-amd64 compressed oops)
        # Problematic frame:
        # V [libjvm.dylib+0x3a8262] PhaseIdealLoop::idom_no_update(Node*) const+0x12
        #
        # Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
        #
        # If you would like to submit a bug report, please visit:
        # http://bugreport.sun.com/bugreport/crash.jsp
        #

        --------------- T H R E A D ---------------

        Current thread (0x00007fb742035800): JavaThread "C2 CompilerThread0" daemon [_thread_in_native, id=18435, stack(0x0000000117a42000,0x0000000117b42000)]

        siginfo:si_signo=SIGSEGV: si_errno=0, si_code=1 (SEGV_MAPERR), si_addr=0x0000000000000008

        Registers:
        RAX=0x0000000000000000, RBX=0x0000000000000002, RCX=0x00007fb741a54a10, RDX=0x00007fb741a27410
        RSP=0x0000000117b3b5b0, RBP=0x0000000117b3b5b0, RSI=0x00007fb741701f10, RDI=0x0000000117b3d088
        R8 =0x0000000000000000, R9 =0x0000000000000001, R10=0x000000000086b93a, R11=0x00000000000004e0
        R12=0x0000000000000003, R13=0x00007fb743015c40, R14=0x0000000000000000, R15=0x00007fb741701f10
        RIP=0x000000010fda8262, EFLAGS=0x0000000000010297, ERR=0x0000000000000004
          TRAPNO=0x000000000000000e

        Top of Stack: (sp=0x0000000117b3b5b0)
        0x0000000117b3b5b0: 0000000117b3b680 000000010fdbacd1
        0x0000000117b3b5c0: 0000000117b3b620 000000000000001a
        0x0000000117b3b5d0: 0000003643016490 000000000000001a
        0x0000000117b3b5e0: 00007fb743016e50 00007fb74150cdf0
        0x0000000117b3b5f0: 0000000000000000 0000000117b3ba90
        0x0000000117b3b600: 0000000000000000 0000000000000000
        0x0000000117b3b610: 00000b1543016648 00007fb743013468
        0x0000000117b3b620: 00007fb743039f50 00007fb743016070
        0x0000000117b3b630: 0000000117b3d088 00007fb74150cdf0
        0x0000000117b3b640: 0000000100000008 00007fb742094f30
        0x0000000117b3b650: 0000000100000003 00007fb7419f8a38
        0x0000000117b3b660: 00007fb743016510 0000000117b41000
        0x0000000117b3b670: 0000000000000000 0000000117b3d088
        0x0000000117b3b680: 0000000117b3b720 000000010fdad350
        0x0000000117b3b690: 00007fb7430164d0 fffffffe41988438
        0x0000000117b3b6a0: 00007fb743015dd0 00007fb700000003
        0x0000000117b3b6b0: 00007fb7419f8900 00007fb742060aa0
        0x0000000117b3b6c0: 00007fb700000035 00007fb7419f89b0
        0x0000000117b3b6d0: 0000000117b3ba90 00007fb743039f50
        0x0000000117b3b6e0: 00007fb7419f8a38 0000000117b3d088
        0x0000000117b3b6f0: 00007fb743016490 0000000117b3d088
        0x0000000117b3b700: 000000011015c101 0000000117b41000
        0x0000000117b3b710: 00007fb743039f50 00007fb7419f8a38
        0x0000000117b3b720: 0000000117b3b770 000000010fdaf6f0
        0x0000000117b3b730: 0000000117b3d088 00017fb743039f50
        0x0000000117b3b740: 0000000117b3ba90 00007fb743039f50
        0x0000000117b3b750: 000000011015c1ca 0000000117b410b8
        0x0000000117b3b760: 0000000117b3ba90 0000000117b3d088
        0x0000000117b3b770: 0000000117b3b7a0 000000010fdaf7c6
        0x0000000117b3b780: 000000011015c1ca 00007fb743039ec0
        0x0000000117b3b790: 0000000117b3ba90 0000000117b3d088
        0x0000000117b3b7a0: 0000000117b3b7d0 000000010fdaf80a

        Instructions: (pc=0x000000010fda8262)
        0x000000010fda8242: 2c 83 e1 07 83 f9 05 48 0f 45 c2 5d c3 90 55 48
        0x000000010fda8252: 89 e5 8b 46 28 48 8b 8f e0 09 00 00 48 8b 04 c1
        0x000000010fda8262: 48 8b 48 08 48 83 39 00 75 26 8b 4f 28 8b 40 28
        0x000000010fda8272: 39 c1 77 0e 31 c0 48 8b 50 08 48 83 3a 00 74 ed

        Register to memory mapping:

        RAX=0x0000000000000000 is an unknown value
        RBX=0x0000000000000002 is an unknown value
        RCX=0x00007fb741a54a10 is an unknown value
        RDX=0x00007fb741a27410 is an unknown value
        RSP=0x0000000117b3b5b0 is pointing into the stack for thread: 0x00007fb742035800
        RBP=0x0000000117b3b5b0 is pointing into the stack for thread: 0x00007fb742035800
        RSI=0x00007fb741701f10 is an unknown value
        RDI=0x0000000117b3d088 is pointing into the stack for thread: 0x00007fb742035800
        R8 =0x0000000000000000 is an unknown value
        R9 =0x0000000000000001 is an unknown value
        R10=0x000000000086b93a is an unknown value
        R11=0x00000000000004e0 is an unknown value
        R12=0x0000000000000003 is an unknown value
        R13=0x00007fb743015c40 is an unknown value
        R14=0x0000000000000000 is an unknown value
        R15=0x00007fb741701f10 is an unknown value


        Stack: [0x0000000117a42000,0x0000000117b42000], sp=0x0000000117b3b5b0, free space=997k
        Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
        V [libjvm.dylib+0x3a8262] PhaseIdealLoop::idom_no_update(Node*) const+0x12
        V [libjvm.dylib+0x3bacd1] PhaseIdealLoop::clone_loop(IdealLoopTree*, Node_List&, int, Node*)+0xadf
        V [libjvm.dylib+0x3ad350] PhaseIdealLoop::do_unroll(IdealLoopTree*, Node_List&, bool)+0xba4
        V [libjvm.dylib+0x3af6f0] IdealLoopTree::iteration_split_impl(PhaseIdealLoop*, Node_List&)+0x206
        V [libjvm.dylib+0x3af7c6] IdealLoopTree::iteration_split(PhaseIdealLoop*, Node_List&)+0xc2
        V [libjvm.dylib+0x3af80a] IdealLoopTree::iteration_split(PhaseIdealLoop*, Node_List&)+0x106
        V [libjvm.dylib+0x3af80a] IdealLoopTree::iteration_split(PhaseIdealLoop*, Node_List&)+0x106
        V [libjvm.dylib+0x3b7ad7] PhaseIdealLoop::build_and_optimize(bool, bool)+0x883
        V [libjvm.dylib+0x1ba324] Compile::Optimize()+0x3e4
        V [libjvm.dylib+0x1bce78] Compile::Compile(ciEnv*, C2Compiler*, ciMethod*, int, bool, bool)+0x882
        V [libjvm.dylib+0x1667d7] C2Compiler::compile_method(ciEnv*, ciMethod*, int)+0x9d
        V [libjvm.dylib+0x1c0018] CompileBroker::invoke_compiler_on_method(CompileTask*)+0x3e0
        V [libjvm.dylib+0x1c1d5a] CompileBroker::compiler_thread_loop()+0x12c
        V [libjvm.dylib+0x4f5c11] JavaThread::thread_main_inner()+0x9b
        V [libjvm.dylib+0x4f7319] JavaThread::run()+0x1a3
        V [libjvm.dylib+0x420b4e] java_start(Thread*)+0x126
        C [libsystem_pthread.dylib+0x1899] _pthread_body+0x8a
        C [libsystem_pthread.dylib+0x172a] _pthread_struct_init+0x0
        C [libsystem_pthread.dylib+0x5fc9] thread_start+0xd


        Current CompileTask:
        C2: 601 64 test.TestLogSum::computeSum (111 bytes)


        --------------- P R O C E S S ---------------

        Java Threads: ( => current thread )
          0x00007fb741852800 JavaThread "Service Thread" daemon [_thread_blocked, id=19459, stack(0x0000000117c48000,0x0000000117d48000)]
          0x00007fb741851000 JavaThread "C2 CompilerThread1" daemon [_thread_in_native, id=18947, stack(0x0000000117b45000,0x0000000117c45000)]
        =>0x00007fb742035800 JavaThread "C2 CompilerThread0" daemon [_thread_in_native, id=18435, stack(0x0000000117a42000,0x0000000117b42000)]
          0x00007fb742803800 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=17923, stack(0x000000011793f000,0x0000000117a3f000)]
          0x00007fb742801800 JavaThread "Finalizer" daemon [_thread_blocked, id=13059, stack(0x00000001176fd000,0x00000001177fd000)]
          0x00007fb742010000 JavaThread "Reference Handler" daemon [_thread_blocked, id=12547, stack(0x00000001175fa000,0x00000001176fa000)]
          0x00007fb742001000 JavaThread "main" [_thread_in_Java, id=6915, stack(0x0000000110460000,0x0000000110560000)]

        Other Threads:
          0x00007fb74184f800 VMThread [stack: 0x00000001174f7000,0x00000001175f7000] [id=12035]
          0x00007fb741851800 WatcherThread [stack: 0x0000000117d4b000,0x0000000117e4b000] [id=19971]

        VM state:not at safepoint (normal execution)

        VM Mutex/Monitor currently owned by a thread: None

        Heap
         PSYoungGen total 19456K, used 5408K [0x00000007eaa80000, 0x00000007ec000000, 0x0000000800000000)
          eden space 16896K, 32% used [0x00000007eaa80000,0x00000007eafc8210,0x00000007ebb00000)
          from space 2560K, 0% used [0x00000007ebd80000,0x00000007ebd80000,0x00000007ec000000)
          to space 2560K, 0% used [0x00000007ebb00000,0x00000007ebb00000,0x00000007ebd80000)
         ParOldGen total 43520K, used 0K [0x00000007c0000000, 0x00000007c2a80000, 0x00000007eaa80000)
          object space 43520K, 0% used [0x00000007c0000000,0x00000007c0000000,0x00000007c2a80000)
         PSPermGen total 21504K, used 2709K [0x00000007bae00000, 0x00000007bc300000, 0x00000007c0000000)
          object space 21504K, 12% used [0x00000007bae00000,0x00000007bb0a5728,0x00000007bc300000)

        Card table byte_map: [0x0000000113622000,0x000000011384c000] byte_map_base: 0x000000010f84b000

        Polling page: 0x000000010f174000

        Code Cache [0x0000000110562000, 0x00000001107d2000, 0x0000000113562000)
         total_blobs=252 nmethods=69 adapters=138 free_code_cache=48626Kb largest_free_block=49776000

        Compilation events (10 events):
        Event: 0.545 Thread 0x00007fb741851000 59 sun.nio.cs.StreamEncoder::writeBytes (132 bytes)
        Event: 0.549 Thread 0x00007fb742035800 nmethod 56 0x00000001105df990 code [0x00000001105dfb80, 0x00000001105e0ec8]
        Event: 0.549 Thread 0x00007fb742035800 60 ! java.io.PrintStream::write (69 bytes)
        Event: 0.564 Thread 0x00007fb741851000 nmethod 59 0x00000001105e6a10 code [0x00000001105e6be0, 0x00000001105e7b48]
        Event: 0.564 Thread 0x00007fb741851000 61 s java.io.BufferedOutputStream::write (67 bytes)
        Event: 0.565 Thread 0x00007fb742035800 nmethod 60 0x00000001105e8490 code [0x00000001105e8640, 0x00000001105e9388]
        Event: 0.565 Thread 0x00007fb742035800 63 java.nio.Buffer::clear (20 bytes)
        Event: 0.566 Thread 0x00007fb742035800 nmethod 63 0x00000001105d3750 code [0x00000001105d3880, 0x00000001105d38f8]
        Event: 0.566 Thread 0x00007fb742035800 64 test.TestLogSum::computeSum (111 bytes)
        Event: 0.569 Thread 0x00007fb741851000 nmethod 61 0x00000001105e4410 code [0x00000001105e4580, 0x00000001105e4b18]

        GC Heap History (0 events):
        No events

        Deoptimization events (0 events):
        No events

        Internal exceptions (10 events):
        Event: 0.107 Thread 0x00007fb742001000 Threw 0x00000007eab68400 at /HUDSON/workspace/7u-2-build-macosx-x86_64/jdk7u60/1081/hotspot/src/share/vm/prims/jvm.cpp:1244
        Event: 0.107 Thread 0x00007fb742001000 Threw 0x00000007eab68528 at /HUDSON/workspace/7u-2-build-macosx-x86_64/jdk7u60/1081/hotspot/src/share/vm/prims/jvm.cpp:1244
        Event: 0.109 Thread 0x00007fb742001000 Threw 0x00000007eab691e8 at /HUDSON/workspace/7u-2-build-macosx-x86_64/jdk7u60/1081/hotspot/src/share/vm/prims/jni.cpp:717
        Event: 0.109 Thread 0x00007fb742001000 Threw 0x00000007eab69308 at /HUDSON/workspace/7u-2-build-macosx-x86_64/jdk7u60/1081/hotspot/src/share/vm/prims/jvm.cpp:1244
        Event: 0.109 Thread 0x00007fb742001000 Threw 0x00000007eab69430 at /HUDSON/workspace/7u-2-build-macosx-x86_64/jdk7u60/1081/hotspot/src/share/vm/prims/jvm.cpp:1244
        Event: 0.112 Thread 0x00007fb742001000 Threw 0x00000007eab7beb0 at /HUDSON/workspace/7u-2-build-macosx-x86_64/jdk7u60/1081/hotspot/src/share/vm/prims/jni.cpp:717
        Event: 0.112 Thread 0x00007fb742001000 Threw 0x00000007eab7bfd0 at /HUDSON/workspace/7u-2-build-macosx-x86_64/jdk7u60/1081/hotspot/src/share/vm/prims/jvm.cpp:1244
        Event: 0.112 Thread 0x00007fb742001000 Threw 0x00000007eab7c0f8 at /HUDSON/workspace/7u-2-build-macosx-x86_64/jdk7u60/1081/hotspot/src/share/vm/prims/jvm.cpp:1244
        Event: 0.112 Thread 0x00007fb742001000 Threw 0x00000007eab7c348 at /HUDSON/workspace/7u-2-build-macosx-x86_64/jdk7u60/1081/hotspot/src/share/vm/prims/jvm.cpp:1244
        Event: 0.120 Thread 0x00007fb742001000 Threw 0x00000007eab84d40 at /HUDSON/workspace/7u-2-build-macosx-x86_64/jdk7u60/1081/hotspot/src/share/vm/prims/jvm.cpp:1244

        Events (10 events):
        Event: 0.122 loading class 0x0000000116268730
        Event: 0.122 loading class 0x0000000116268730 done
        Event: 0.122 loading class 0x000000011628bae0
        Event: 0.122 loading class 0x000000011628bae0 done
        Event: 0.123 loading class 0x000000011628e630
        Event: 0.123 loading class 0x000000011628e730
        Event: 0.123 loading class 0x000000011628e730 done
        Event: 0.123 loading class 0x000000011628e630 done
        Event: 0.261 loading class 0x000000011628e700
        Event: 0.261 loading class 0x000000011628e700 done


        Dynamic libraries:
        0x0000000000481000 /System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa
        0x0000000000481000 /System/Library/Frameworks/Security.framework/Versions/A/Security
        0x0000000000481000 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/ApplicationServices
        0x0000000000481000 /usr/lib/libz.1.dylib
        0x0000000000481000 /usr/lib/libSystem.B.dylib
        0x0000000000481000 /usr/lib/libobjc.A.dylib
        0x0000000000481000 /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation
        0x0000000000481000 /System/Library/Frameworks/Foundation.framework/Versions/C/Foundation
        0x0000000000481000 /System/Library/Frameworks/AppKit.framework/Versions/C/AppKit
        0x0000000000481000 /System/Library/Frameworks/CoreData.framework/Versions/A/CoreData
        0x0000000000481000 /System/Library/PrivateFrameworks/RemoteViewServices.framework/Versions/A/RemoteViewServices
        0x0000000000481000 /System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox
        0x0000000000481000 /System/Library/Frameworks/AudioUnit.framework/Versions/A/AudioUnit
        0x0000000000481000 /System/Library/PrivateFrameworks/DataDetectorsCore.framework/Versions/A/DataDetectorsCore
        0x0000000000481000 /System/Library/PrivateFrameworks/DesktopServicesPriv.framework/Versions/A/DesktopServicesPriv
        0x0000000000481000 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/HIToolbox.framework/Versions/A/HIToolbox
        0x0000000000481000 /System/Library/Frameworks/QuartzCore.framework/Versions/A/QuartzCore
        0x0000000000481000 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SpeechRecognition.framework/Versions/A/SpeechRecognition
        0x0000000000481000 /usr/lib/libauto.dylib
        0x0000000000481000 /usr/lib/libicucore.A.dylib
        0x0000000000481000 /usr/lib/libxml2.2.dylib
        0x0000000000481000 /System/Library/PrivateFrameworks/CoreUI.framework/Versions/A/CoreUI
        0x0000000000481000 /System/Library/Frameworks/CoreAudio.framework/Versions/A/CoreAudio
        0x0000000000481000 /System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration
        0x0000000000481000 /usr/lib/liblangid.dylib
        0x0000000000481000 /System/Library/PrivateFrameworks/MultitouchSupport.framework/Versions/A/MultitouchSupport
        0x0000000000481000 /System/Library/Frameworks/IOKit.framework/Versions/A/IOKit
        0x0000000000481000 /usr/lib/libDiagnosticMessagesClient.dylib
        0x0000000000481000 /System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices
        0x0000000000481000 /System/Library/PrivateFrameworks/PerformanceAnalysis.framework/Versions/A/PerformanceAnalysis
        0x0000000000481000 /System/Library/PrivateFrameworks/GenerationalStorage.framework/Versions/A/GenerationalStorage
        0x0000000000481000 /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL
        0x0000000000481000 /System/Library/PrivateFrameworks/Sharing.framework/Versions/A/Sharing
        0x0000000000481000 /System/Library/Frameworks/ImageIO.framework/Versions/A/ImageIO
        0x0000000000481000 /System/Library/Frameworks/CoreText.framework/Versions/A/CoreText
        0x0000000000481000 /System/Library/Frameworks/CoreGraphics.framework/Versions/A/CoreGraphics
        0x0000000000481000 /System/Library/PrivateFrameworks/Backup.framework/Versions/A/Backup
        0x0000000000481000 /System/Library/Frameworks/CFNetwork.framework/Versions/A/CFNetwork
        0x0000000000481000 /System/Library/Frameworks/SystemConfiguration.framework/Versions/A/SystemConfiguration
        0x0000000000481000 /usr/lib/libCRFSuite.dylib
        0x0000000000481000 /usr/lib/libc++.1.dylib
        0x0000000000481000 /usr/lib/libc++abi.dylib
        0x0000000000481000 /usr/lib/system/libcache.dylib
        0x0000000000481000 /usr/lib/system/libcommonCrypto.dylib
        0x0000000000481000 /usr/lib/system/libcompiler_rt.dylib
        0x0000000000481000 /usr/lib/system/libcopyfile.dylib
        0x0000000000481000 /usr/lib/system/libcorecrypto.dylib
        0x0000000000481000 /usr/lib/system/libdispatch.dylib
        0x0000000000481000 /usr/lib/system/libdyld.dylib
        0x0000000000481000 /usr/lib/system/libkeymgr.dylib
        0x0000000000481000 /usr/lib/system/liblaunch.dylib
        0x0000000000481000 /usr/lib/system/libmacho.dylib
        0x0000000000481000 /usr/lib/system/libquarantine.dylib
        0x0000000000481000 /usr/lib/system/libremovefile.dylib
        0x0000000000481000 /usr/lib/system/libsystem_asl.dylib
        0x0000000000481000 /usr/lib/system/libsystem_blocks.dylib
        0x0000000000481000 /usr/lib/system/libsystem_c.dylib
        0x0000000000481000 /usr/lib/system/libsystem_configuration.dylib
        0x0000000000481000 /usr/lib/system/libsystem_dnssd.dylib
        0x0000000000481000 /usr/lib/system/libsystem_info.dylib
        0x0000000000481000 /usr/lib/system/libsystem_kernel.dylib
        0x0000000000481000 /usr/lib/system/libsystem_m.dylib
        0x0000000000481000 /usr/lib/system/libsystem_malloc.dylib
        0x0000000000481000 /usr/lib/system/libsystem_network.dylib
        0x0000000000481000 /usr/lib/system/libsystem_notify.dylib
        0x0000000000481000 /usr/lib/system/libsystem_platform.dylib
        0x0000000000481000 /usr/lib/system/libsystem_pthread.dylib
        0x0000000000481000 /usr/lib/system/libsystem_sandbox.dylib
        0x0000000000481000 /usr/lib/system/libsystem_stats.dylib
        0x0000000000481000 /usr/lib/system/libunc.dylib
        0x0000000000481000 /usr/lib/system/libunwind.dylib
        0x0000000000481000 /usr/lib/system/libxpc.dylib
        0x0000000000481000 /usr/lib/libbsm.0.dylib
        0x0000000000481000 /usr/lib/libsqlite3.dylib
        0x0000000000481000 /usr/lib/libxar.1.dylib
        0x0000000000481000 /usr/lib/libpam.2.dylib
        0x0000000000481000 /usr/lib/libOpenScriptingUtil.dylib
        0x0000000000481000 /usr/lib/libbz2.1.0.dylib
        0x0000000000481000 /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/CarbonCore
        0x0000000000481000 /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/Metadata.framework/Versions/A/Metadata
        0x0000000000481000 /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/OSServices.framework/Versions/A/OSServices
        0x0000000000481000 /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SearchKit.framework/Versions/A/SearchKit
        0x0000000000481000 /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/AE
        0x0000000000481000 /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/LaunchServices
        0x0000000000481000 /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/DictionaryServices.framework/Versions/A/DictionaryServices
        0x0000000000481000 /System/Library/Frameworks/NetFS.framework/Versions/A/NetFS
        0x0000000000481000 /usr/lib/system/libkxld.dylib
        0x0000000000481000 /System/Library/PrivateFrameworks/NetAuth.framework/Versions/A/NetAuth
        0x0000000000481000 /System/Library/PrivateFrameworks/TCC.framework/Versions/A/TCC
        0x0000000000481000 /System/Library/Frameworks/OpenDirectory.framework/Versions/A/Frameworks/CFOpenDirectory.framework/Versions/A/CFOpenDirectory
        0x0000000000481000 /System/Library/Frameworks/ServiceManagement.framework/Versions/A/ServiceManagement
        0x0000000000481000 /usr/lib/libxslt.1.dylib
        0x0000000000481000 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Ink.framework/Versions/A/Ink
        0x0000000000481000 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/ATS
        0x0000000000481000 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ColorSync.framework/Versions/A/ColorSync
        0x0000000000481000 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/HIServices.framework/Versions/A/HIServices
        0x0000000000481000 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/LangAnalysis.framework/Versions/A/LangAnalysis
        0x0000000000481000 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/PrintCore.framework/Versions/A/PrintCore
        0x0000000000481000 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/QD.framework/Versions/A/QD
        0x0000000000481000 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/SpeechSynthesis.framework/Versions/A/SpeechSynthesis
        0x0000000000481000 /System/Library/Frameworks/IOSurface.framework/Versions/A/IOSurface
        0x0000000000481000 /System/Library/Frameworks/Accelerate.framework/Versions/A/Accelerate
        0x0000000000481000 /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vImage.framework/Versions/A/vImage
        0x0000000000481000 /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/vecLib
        0x0000000000481000 /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvDSP.dylib
        0x0000000000481000 /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libvMisc.dylib
        0x0000000000481000 /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libLAPACK.dylib
        0x0000000000481000 /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
        0x0000000000481000 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Resources/libFontParser.dylib
        0x0000000000481000 /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ATS.framework/Versions/A/Resources/libFontRegistry.dylib
        0x0000000000481000 /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libJPEG.dylib
        0x0000000000481000 /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libTIFF.dylib
        0x0000000000481000 /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libPng.dylib
        0x0000000000481000 /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libGIF.dylib
        0x0000000000481000 /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libJP2.dylib
        0x0000000000481000 /System/Library/Frameworks/ImageIO.framework/Versions/A/Resources/libRadiance.dylib
        0x0000000000481000 /usr/lib/libcups.2.dylib
        0x0000000000481000 /System/Library/Frameworks/Kerberos.framework/Versions/A/Kerberos
        0x0000000000481000 /System/Library/Frameworks/GSS.framework/Versions/A/GSS
        0x0000000000481000 /usr/lib/libresolv.9.dylib
        0x0000000000481000 /usr/lib/libiconv.2.dylib
        0x0000000000481000 /System/Library/PrivateFrameworks/Heimdal.framework/Versions/A/Heimdal
        0x0000000000481000 /System/Library/PrivateFrameworks/TrustEvaluationAgent.framework/Versions/A/TrustEvaluationAgent
        0x0000000000481000 /usr/lib/libheimdal-asn1.dylib
        0x0000000000481000 /System/Library/Frameworks/OpenDirectory.framework/Versions/A/OpenDirectory
        0x0000000000481000 /System/Library/PrivateFrameworks/CommonAuth.framework/Versions/A/CommonAuth
        0x0000000000481000 /System/Library/Frameworks/SecurityFoundation.framework/Versions/A/SecurityFoundation
        0x0000000000481000 /System/Library/PrivateFrameworks/Bom.framework/Versions/A/Bom
        0x0000000000481000 /System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo
        0x0000000000481000 /System/Library/Frameworks/QuartzCore.framework/Versions/A/Frameworks/CoreImage.framework/Versions/A/CoreImage
        0x0000000000481000 /System/Library/Frameworks/QuartzCore.framework/Versions/A/Frameworks/ScalableUserInterface.framework/Versions/A/ScalableUserInterface
        0x0000000000481000 /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib
        0x0000000000481000 /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGFXShared.dylib
        0x0000000000481000 /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib
        0x0000000000481000 /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLImage.dylib
        0x0000000000481000 /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libCVMSPluginSupport.dylib
        0x0000000000481000 /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libCoreVMClient.dylib
        0x0000000000481000 /System/Library/PrivateFrameworks/FaceCore.framework/Versions/A/FaceCore
        0x0000000000481000 /System/Library/PrivateFrameworks/CrashReporterSupport.framework/Versions/A/CrashReporterSupport
        0x0000000000481000 /System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL
        0x0000000000481000 /System/Library/PrivateFrameworks/AppleFSCompression.framework/Versions/A/AppleFSCompression
        0x0000000000481000 /System/Library/PrivateFrameworks/Ubiquity.framework/Versions/A/Ubiquity
        0x0000000000481000 /System/Library/PrivateFrameworks/IconServices.framework/Versions/A/IconServices
        0x0000000000481000 /System/Library/PrivateFrameworks/ChunkingLibrary.framework/Versions/A/ChunkingLibrary
        0x0000000000481000 /System/Library/PrivateFrameworks/CoreSymbolication.framework/Versions/A/CoreSymbolication
        0x0000000000481000 /System/Library/PrivateFrameworks/Symbolication.framework/Versions/A/Symbolication
        0x0000000000481000 /System/Library/PrivateFrameworks/DebugSymbols.framework/Versions/A/DebugSymbols
        0x000000010fa00000 /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/jre/lib/server/libjvm.dylib
        0x0000000000481000 /usr/lib/libstdc++.6.dylib
        0x000000010f137000 /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/jre/lib/libverify.dylib
        0x000000010f144000 /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/jre/lib/libjava.dylib
        0x000000010f17e000 /Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/jre/lib/libzip.dylib
        0x00000001177ff000 /System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/JavaRuntimeSupport
        0x0000000117817000 /System/Library/Frameworks/JavaVM.framework/Versions/A/Frameworks/JavaNativeFoundation.framework/Versions/A/JavaNativeFoundation
        0x000000010f1ef000 /System/Library/Frameworks/JavaVM.framework/Versions/A/JavaVM
        0x0000000000481000 /System/Library/Frameworks/Carbon.framework/Versions/A/Carbon
        0x000000011782c000 /System/Library/PrivateFrameworks/JavaLaunching.framework/Versions/A/JavaLaunching
        0x0000000000481000 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/CommonPanels.framework/Versions/A/CommonPanels
        0x0000000000481000 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Help.framework/Versions/A/Help
        0x0000000000481000 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/ImageCapture.framework/Versions/A/ImageCapture
        0x0000000000481000 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/OpenScripting.framework/Versions/A/OpenScripting
        0x0000000000481000 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/Print.framework/Versions/A/Print
        0x0000000000481000 /System/Library/Frameworks/Carbon.framework/Versions/A/Frameworks/SecurityHI.framework/Versions/A/SecurityHI

        VM Arguments:
        jvm_args: -XX:-UseLoopPredicate -Dfile.encoding=UTF-8
        java_command: test.TestLogSum
        Launcher Type: SUN_STANDARD

        Environment Variables:
        PATH=/usr/bin:/bin:/usr/sbin:/sbin
        SHELL=/bin/bash
        DISPLAY=/tmp/launch-XDqolO/org.macosforge.xquartz:0

        Signal Handlers:
        SIGSEGV: [libjvm.dylib+0x52b7b1], sa_mask[0]=0xfffefeff, sa_flags=0x00000043
        SIGBUS: [libjvm.dylib+0x52b7b1], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
        SIGFPE: [libjvm.dylib+0x41e28a], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
        SIGPIPE: [libjvm.dylib+0x41e28a], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
        SIGXFSZ: [libjvm.dylib+0x41e28a], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
        SIGILL: [libjvm.dylib+0x41e28a], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
        SIGUSR1: SIG_DFL, sa_mask[0]=0x00000000, sa_flags=0x00000002
        SIGUSR2: [libjvm.dylib+0x41dd7c], sa_mask[0]=0x00000004, sa_flags=0x00000042
        SIGHUP: [libjvm.dylib+0x41c00b], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
        SIGINT: [libjvm.dylib+0x41c00b], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
        SIGTERM: [libjvm.dylib+0x41c00b], sa_mask[0]=0xfffefeff, sa_flags=0x00000042
        SIGQUIT: [libjvm.dylib+0x41c00b], sa_mask[0]=0xfffefeff, sa_flags=0x00000042


        --------------- S Y S T E M ---------------

        OS:Bsduname:Darwin 13.1.0 Darwin Kernel Version 13.1.0: Thu Jan 16 19:40:37 PST 2014; root:xnu-2422.90.20~2/RELEASE_X86_64 x86_64
        rlimit: STACK 8192k, CORE 0k, NPROC 709, NOFILE 10240, AS infinity
        load average:1.87 2.58 3.25

        CPU:total 4 (2 cores per cpu, 2 threads per core) family 6 model 37 stepping 2, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3, sse4.1, sse4.2, popcnt, aes, ht, tsc, tscinvbit

        Memory: 4k page, physical 4194304k(1048576k free)

        /proc/meminfo:


        vm_info: Java HotSpot(TM) 64-Bit Server VM (24.60-b09) for bsd-amd64 JRE (1.7.0_60-b19), built on May 7 2014 12:52:25 by "java_re" with gcc 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)

        time: Sun Jun 8 12:45:07 2014
        elapsed time: 0 seconds

         

        REPRODUCIBILITY :
        This bug can be reproduced often.

        ---------- BEGIN SOURCE ----------
        import java.util.Arrays;
        import java.util.HashMap;
        import java.util.List;
        import java.util.Map;
        public class TestLogSum {
            public static void main(String[] args) {

                for (int i = 0; i < 6; i++) {
                    for (int n = 2; n < 30; n++) {
                        for (int j = 1; j <= n; j++) {
                            for (int k = 1; k <= j; k++) {
                                System.out.println(computeSum(k, j));
                            }
                        }
                    }
                }
            }

            private static Map<List<Integer>, Double> cache = new HashMap<List<Integer>, Double>();
            public static double computeSum(int x, int y) {
                List<Integer> key = Arrays.asList(new Integer[] {x, y});

                if (!cache.containsKey(key)) {

                    // explicitly creating/updating a double[] array, instead of using the LogSumArray wrapper object, will prevent the error
                    LogSumArray toReturn = new LogSumArray(x);

                    // changing loop indices will prevent the error
                    // in particular, for(z=0; z<x-1; z++), and then using z+1 in place of z, will not produce error
        // for (int z = 0; z < x; z++) {
        // double logSummand = Math.log(1 + z + x + y);
                    for (int z = 1; z < x+1; z++) {
                        double logSummand = Math.log(z + x + y);
                        toReturn.addLogSummand(logSummand);
                    }

                    // returning the value here without cacheing it will prevent the segfault
                    cache.put(key, toReturn.retrieveLogSum());
                }
                return cache.get(key);
            }

            /*
             * Given a bunch of logarithms log(X),log(Y),log(Z),...
             * This class is used to compute the log of the sum, log(X+Y+Z+...)
             */
            private static class LogSumArray {
                private double[] logSummandArray;
                private int currSize;

                private double maxLogSummand;

                public LogSumArray(int maxEntries) {
                    this.logSummandArray = new double[maxEntries];

                    this.currSize = 0;
                    this.maxLogSummand = Double.NEGATIVE_INFINITY;
                }

                public void addLogSummand(double logSummand) {
                    logSummandArray[currSize] = logSummand;
                    currSize++;
                    // removing this line will prevent the error
                    maxLogSummand = Math.max(maxLogSummand, logSummand);
                }

                public double retrieveLogSum() {
                    if (maxLogSummand == Double.NEGATIVE_INFINITY) return Double.NEGATIVE_INFINITY;

                    assert currSize <= logSummandArray.length;

                    double factorSum = 0;
                    for (int i = 0; i < currSize; i++) {
                        factorSum += Math.exp(logSummandArray[i] - maxLogSummand);
                    }

                    return Math.log(factorSum) + maxLogSummand;
                }
            }
        }

        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        Rather than using an array to store all the log summands and then compute the logarithm of the sum in the most numerically stable way possible, I just store the sum and update it one number at a time (this is slightly less numerically stable).

              kvn Vladimir Kozlov
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: