Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 08f20683aa0ff0affb590ec0ed801a9c3149ec5d
Ticket: 1061224fffffffffffffffffffffffffffffffff
"expr sqrt(-1)" crash with EXCEPTION_FLT_INVALID_OPERATION
User & Date: davygrvy on 2004-11-05 22:32:45
Changes

  1. assignee changed to: "kennykb"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    Stack trace:
    KERNEL32! RaiseException
    MSVCRTD! _raise_exc
    MSVCRTD! _87except
    MSVCRTD! _startOneArgErrorHandling
    MSVCRTD! sqrt
    TclExecuteByteCode
    TclCompEvalObj
    Tcl_EvalObjEx
    NamespaceEvalCmd
    Tcl_NamespaceObjCmd
    TclEvalObjvInternal
    TclExecuteByteCode
    TclCompEvalObj
    Tcl_EvalObjEx
    Tcl_CatchObjCmd
    TclEvalObjvInterna
    TclExecuteByteCode
    Tcl_ExprObj
    Tcl_ExprBooleanObj
    Tcl_IfObjCmd
    TclEvalObjvInternal
    Tcl_EvalEx
    Tcl_Eva
    fake_Tcl_Eval
    
    The script I asked it to eval was "expr sqrt(-1)". 
    When my fake_Tcl_Eval() modifies the registers as you
    suggested, the app killing exception 0xC0000090 is avoided:
    
    int
    fake_Tcl_Eval (Tcl_Interp *interp, char *string)
    {
        Tcl_DString dst;
        int result;
    
        Tcl_DStringInit(&dst);
    
        // ensure no upper ascii character combos look like
        // UTF-8 start codes.
        //
        Tcl_ExternalToUtfDString(XiRCEncoding, string, -1,
    &dst);
    
        int mask = _controlfp( 0, 0 );
        // Some math functions need to be protected from
    raising
        // exceptions: /tcl expr sqrt(-1)
        _controlfp( _CW_DEFAULT, _MCW_EM );
    
        result = Tcl_Eval(interp, Tcl_DStringValue(&dst));
    
        _controlfp( mask, _MCW_EM );
        Tcl_DStringFree(&dst);
        return result;
    }
    
    Can Tcl assume the responsibility of protecting it's
    own math calls by this method rather than the client of
    the API?
    
    
  4. foundin changed to: "obsolete: 8.5a2"
  5. priority changed to: "5 Medium"
  6. resolution changed to: "None"
  7. status changed to: "Open"
  8. submitter changed to: "davygrvy"
  9. subsystem changed to: "50. Embedding Support"
  10. title changed to:
    math functions can cause unwanted exceptions and termination
    
  11. type changed to: "Bug"