segfault error

Issue #33 resolved
skaluzka created an issue

hello,

it looks that I have unintentionally found segmentation error. it occurs for report command:

report fileName lineNumber message

when string is used for lineNumber. below script causes segfault error on my machine:

#!/usr/bin/tclsh
# segmentation fault error

set fileName "fileName"
set lineNumber ""; #let's use an empty string instead of integer for line number
set msg "an example report message"

report $fileName $lineNumber $msg

this could be corrected in upcoming releases

Comments (5)

  1. Gaëtan Lehmann

    I've reproduced this bug here. It seems to be related to the tcl stack display on tcl error introduced in vera++ 1.2.0.

    Stack trace is

    #0  0x0000000100342b99 in Tcl_GetString ()
    #1  0x000000010002c449 in Tcl::tcl_error::tcl_error (this=0x1018022e8, interp=0x10082be10) at cpptcl.h:35
    #2  0x0000000100019f9d in Tcl::tcl_error::tcl_error (this=0x1018022e8, interp=0x10082be10) at cpptcl.h:35
    #3  0x00000001000197ce in Tcl::details::tcl_cast<int>::from (interp=0x10082be10, obj=0x100835260) at /Users/glehmann/src/vera/src/plugins/cpptcl-1.1.4/cpptcl.cpp:1042
    #4  0x000000010003767c in Tcl::details::callback3<void, std::string const&, int, std::string const&>::invoke (this=0x101802d90, interp=0x10082be10, objc=4, objv=0x1008396e0) at callbacks.h:93
    #5  0x0000000100015fd0 in callback_handler (interp=0x10082be10, objc=4, objv=0x1008396e0) at /Users/glehmann/src/vera/src/plugins/cpptcl-1.1.4/cpptcl.cpp:322
    #6  0x00000001002d80b7 in Tcl_GetMathFuncInfo ()
    #7  0x00000001002d8d14 in Tcl_GetMathFuncInfo ()
    #8  0x00000001002d90d2 in Tcl_Eval ()
    #9  0x0000000100019117 in Tcl::interpreter::eval (this=0x7fff5fbfd708, script=@0x7fff5fbfd738) at /Users/glehmann/src/vera/src/plugins/cpptcl-1.1.4/cpptcl.cpp:903
    #10 0x0000000100030a9c in Vera::Plugins::Interpreter::executeTcl (root=@0x7fff5fbfdef0, type=Vera::Plugins::Interpreter::rule, fileName=@0x7fff5fbfde58) at /Users/glehmann/src/vera/src/plugins/Interpreter.cpp:202
    #11 0x0000000100030613 in Vera::Plugins::Interpreter::execute (root=@0x7fff5fbfdef0, type=Vera::Plugins::Interpreter::rule, name=@0x10040c700) at /Users/glehmann/src/vera/src/plugins/Interpreter.cpp:167
    #12 0x0000000100045eb6 in Vera::Plugins::Rules::executeRule (name=@0x10040c700) at /Users/glehmann/src/vera/src/plugins/Rules.cpp:31
    #13 0x0000000100005a4c in boost_main (argc=6, argv=0x7fff5fbff580) at /Users/glehmann/src/vera/src/boost_main.cpp:306
    #14 0x00000001000148ea in main (argc=6, argv=0x7fff5fbff580) at /Users/glehmann/src/vera/src/main.cpp:64
    

    cpptcl.h:35 is

              Tcl_GetString(Tcl_GetVar2Ex(interp, "errorInfo", NULL, TCL_GLOBAL_ONLY))){}
    
  2. skaluzka reporter

    hi,

    thanks for the fix, I have checked that ant it works well now. but I am curious what about negative line numbers?

    #!/usr/bin/tclsh
    
    set fileName "fileName"
    set lineNumber -4; #negative integer for line number
    set msg "an example report message"
    
    report $fileName $lineNumber $msg
    

    for instance documentation says (https://bitbucket.org/verateam/vera/wiki/ScriptAPI):

    getLine fileName lineNumber - returns the selected line; line numbers are counted from 1.

    is it allow to use negative integer numbers for lines numbering?

  3. Log in to comment