Skip to main content

Products   >   IBM Systems   >   System z   >   z/OS   >  

APAR PQ60892

Language Environment Support for Java Stack Overflow

Two new CWI's (compiler-writer interfaces) have been added:

  • __set_stack_softlimit()

    __set_stack_softlimit() is used to set the 'Soft Stack Size Limit' (C/C++ and XPLINK only). It is invoked on each thread that you want LE to monitor and enforce a stack size limit.

    When Language Environment attempts to expand the stack and the additional stack segment could cause the total stack size to exceed the MaximumStackSize, a SIGSEGV with an si_code of _SEGV_SOFTLIMIT is generated. As a result of the SIGSEGV, a signal handler is driven and is passed information that represents the environment at the point of stack overflow. This includes register contents, psw contents, and signal mask contents. The signal handler has the option of releasing stack storage and using the passed data to perform a __far_jump() to the original point of overflow in Language Environment, trying the stack segment request again. If a signal handler was registered but the SA_INFO flag was not set, the SIGSEGV signal is delivered but no extra information is passed to the signal handler.

    The initial stack softlimit value that existed before issuing any __set_stack_softlimit() requests is the ULONG_MAX value. This disables the softlimit from being reached. Because this function returns the current softlimit value, the first time it is invoked, it returns the ULONG_MAX value. The function always sets the softlimit to the passed MaximumStackSize value and returns the previous softlimit value.

    Syntax:

    #include

    unsigned long_stack_softlimit (unsigned long MaximumStackSize);

    unsigned long MaximumStackSize MaximumStackSize is the stack size, in bytes. This is a thread-specific value. It is also a 'soft' limit, which means that the actual stack size can grow beyond this limit. You can specify MaximumStackSize back to the ULONG_MAX value, which disables the softlimit.

    Returned Value:

    The __set_stack_softlimit() returns the previous value of the soft limit. This function does not fail and no errors are defined.

    Usage Notes:

    • The SIGSEGV is generated for the thread whose stack has grown beyond the maximum size.
    • The SIGSEGV is generated regardless of whether a signal handler function for SIGSEGVs has been registered.
    • No attempt is made to guarantee that there is sufficient available stack space to deliver the signal, or that there is a minimum amount of available stack space.
    • If a signal handler function for SIGSEGV was registered with the SA_SIGINFO flag and using the sa_sigaction field to identify the handler function, an si_code of, _SEGV_SOFTLIMIT(defined in signal.h), will be reported to the signal handler.
    • The soft limit overflow is not detected until a stack extension is requested. Therefore if a stack initial size has been selected that is greater than the soft limit the stack size will grow past the soft limit, and will not be detected until the initial stack size is exceeded.
    • The header file, <edcwccwi.h>, is located in member EDCWCCWI of the SCEESAMP data set. In order to include <edcwccwi.h> in an application, the header file must be copied into a PDS or an HFS directory in which the C/C++ compiler will find it.

    New Messages:

    CEE0815E The stack soft limit set by the __set_stack_softlimit() function has been exceeded.

    Explanation: During prologue processing the stack soft limit set by the __set_stack_softlimit() function has been exceeded.

    System Action: A SIGSEGV signal with a si_code of _SEGV_SOFTLIMIT is delivered to the thread where the soft limit was exceeded.

    Symbolic Feedback Code: CEE0PF

  • __far_jump()

    __far_jump() is used to perform a Far_Jump. This is a longjmp for which no setjmp had been performed. A 'jump buffer' will be dynamically created by LE using information provided by the invoker of this new CWI. This jump buffer will specify information as to where to jump to.

    The __far_jump() interface performs a function similar to longjmp(). However, it does not require a setjmp() to be performed previously. The information required to perform this "nonlocal goto" is provided by the user in the __jumpinfo structure. This information is normally provided in a jmp_buf and saved by the library when a setjmp() is invoked. When used in conjunction with __set_stack_softlimit(), the information needed to jump to the point of retry can be obtained from data passed to a signal handler set up to field a softlimit stack overflow signal. This information includes registers, psw, and signal mask.

    Syntax:

    #include <edcwccwi.h>

    void __far_jump (struct __jumpinfo* JumpInfo);

    The __jumpinfo structure appears in the following format:

    struct __jumpinfo { char __ji_u1[68]; char __ji_mask_saved; char __ji_u2[3]; sigset_t __ji_sigmask; char __ji_u3[11]; unsigned __ji_fl_fp4 :1; unsigned __ji_fl_fp16 :1; unsigned __ji_fl_fpc :1; unsigned __ji_fl_res1a :1; unsigned __ji_fl_hr :1; unsigned __ji_fl_res2 :1; unsigned __ji_fl_exp :1; unsigned __ji_fl_res2a :1; char __ji_u4[36]; long __ji_gr[16]; long __ji_hr[16]; int __ji_u5[16]; double __ji_fpr[16]; int __ji_fpc;

    • __ji_gr
      • The values of the 16 general purpose registers that are restored
      • The value in Register 7 will be used as the target address of the jump
      • The value of Register 4 will be used as the target DSA address
    • __ji_hr
      • Indicates the values of the 16 general purpose registers that are restored. This is valid only on 64 bit hardware when running in 31 bit mode.
    • __ji_fpr
      • Indicates the values of the 16 floating-point registers.
    • __ji_mask_saved
      • Indicator field that is set to non-zero value when the signal mask field (__ji_sigmask) is valid.
    • __ji_sigmask
      • Indicates the signal mask value.
    • __ji_fpc
      • Indicates the floating point control register value.
    • __ji_fl_fp4
      • The binary switch set to one when 4 floating point registers are provided.
    • __ji_fl_fp16
      • The binary switch set to one when 16 floating point registers are provided.
    • __ji_fl_fpc
      • The binary switch set to one when 4 floating point control register is provided.
    • __ji_fl_exp
      • The binary switch set to one when explicit backchaining is complete to the target stack.
    • __ji_fl_hr
      • The binary switch set to one when the 4 floating point control register is provided.

    Returned Value:

    The __far_jump() function has no returned value. When __far_jump() completes, program execution continues at the target address.

    Usage notes:

    • The library does not attempt to verify the contents of the __jumpinfo structure. Incorrect data can lead to unpredictable results.
    • The caller of __far_jump can optionally supply a signal mask suitable to the target of the jump. It is usually required in the soft overflow scenario because the signal handler, which is the __far_jump invoker, is driven with SIGSEGV disabled. However, SIGSEGV must be enabled at resumption in the target.
    • The caller of __far_jump provides the GPR & FPR sets needed for the target of the __far_jump. The GPR set is always complete. For example, it has all 16 registers, including the target DSA address in R4 and target code address in R7. The FPR set is 4 or 16 registers long, indicated by the accompanying switches.
    • The contents of all registers at the point of resumption after a __far_jump are the values specified in the __jumpinfo buffer. The target address of the jump is not supplied separately. It is supplied as two of the register values in the GPR set in the __jumpinfo buffer, R4 for the target DSA address and R7 for the target code address.
    • The header file, <edcwccwi.h>, is located in member EDCWCCWI of the SCEESAMP data set. In order to include <edcwccwi.h> in an application, the header file must be copied into a PDS or an HFS directory in which the C/C++ compiler will find it.