Skip to content
Tcl Source Code History Of Ticket cd61f085da52b338
Login

History Of Ticket cd61f085da52b338

Artifacts Associated With Ticket cd61f085da52b338

  1. Ticket change [d081f3a5ee] (rid 217414) by juliannoble2 on 2023-08-28 09:06:22:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-plain"
    4. comment initialized to:
      With a script or from tcl shell - Tcl version 8.7 or 9
      
      Execute the command
      
      expr {0x_}
      or
      expr {0d_} 
      or 
      expr {0b_}
      or
      expr {0o_}
      
      The interpreter will silently exit.
      
      Expected: an error to be raised.
      
    5. foundin initialized to: "8.7, 9"
    6. is_private initialized to: "0"
    7. login: "juliannoble2"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "957fdfcd8744611e3fe1f4896c7538b1d9bf47b2"
    10. resolution initialized to: "None"
    11. severity initialized to: "Important"
    12. status initialized to: "Open"
    13. submitter initialized to: "juliannoble2"
    14. subsystem initialized to: "- New Builtin Commands"
    15. title initialized to:
      tcl terminates silently with invalid expr underscore syntax and radix prefix
      
    16. type initialized to: "Bug"
  2. Ticket change [061e388bf4] (rid 217415) by juliannoble2 on 2023-08-28 09:27:26:

    1. icomment:
      This also happens if a character outside of the range expected by the radix follows the underscore
      e.g
      expr {0d_a12}
      expr {0b_21010}
      expr {0x_GFF}
      expr {0o_876}
      
    2. login: "juliannoble2"
    3. mimetype: "text/plain"
  3. Ticket change [bc8eb3c132] (rid 217416) by chrstphrchvz on 2023-08-28 09:29:40:

    1. icomment:
      I tried this and got a stack overflow.
      
      <pre>
      % expr {0x_}
      AddressSanitizer:DEADLYSIGNAL
      =================================================================
      ==36708==ERROR: AddressSanitizer: stack-overflow on address 0x7ff7bac29fd0 (pc 0x000105031987 bp 0x7ff7bac2a030 sp 0x7ff7bac29fd0 T0)
          #0 0x105031987 in __sanitizer::StackDepotBase<__sanitizer::StackDepotNode, 1, 20>::Put(__sanitizer::StackTrace, bool*)+0x17 (libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x106987)
          #1 0x104f2f28c in __asan::Allocator::Allocate(unsigned long, unsigned long, __sanitizer::BufferedStackTrace*, __asan::AllocType, bool)+0x3cc (libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x428c)
          #2 0x104f2ee98 in __asan::asan_malloc(unsigned long, __sanitizer::BufferedStackTrace*)+0x28 (libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x3e98)
          #3 0x1050087a0 in wrap_malloc+0x100 (libclang_rt.asan_osx_dynamic.dylib:x86_64h+0xdd7a0)
          #4 0x1066fca54 in TclpAlloc tclAlloc.c:699
          #5 0x1067fb224 in Tcl_Alloc tclCkalloc.c:1038
          #6 0x106f1ef5c in ParseLexeme tclCompExpr.c:2090
          #7 0x106f2014f in ParseLexeme tclCompExpr.c:2127
          #8 0x106f2014f in ParseLexeme tclCompExpr.c:2127
          #9 0x106f2014f in ParseLexeme tclCompExpr.c:2127
      ⋮
          #254 0x106f2014f in ParseLexeme tclCompExpr.c:2127
      
      SUMMARY: AddressSanitizer: stack-overflow (libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x106987) in __sanitizer::StackDepotBase<__sanitizer::StackDepotNode, 1, 20>::Put(__sanitizer::StackTrace, bool*)+0x17
      ==36708==ABORTING
      </pre>
      
    2. login: "chrstphrchvz"
    3. mimetype: "text/x-fossil-wiki"
  4. Ticket change [4fcc78a5bd] (rid 217417) by jan.nijtmans on 2023-08-28 09:56:11:

    1. assignee changed to: "griffin"
    2. login: "jan.nijtmans"
    3. mimetype: "text/plain"
  5. Ticket change [23d811aad4] (rid 217418) by juliannoble2 on 2023-08-28 10:12:28:

    1. icomment:
      This doesn't appear to be exclusive to the radix prefixes
      Also with malformed scientific notation:
      
      expr {2.1e_}
      
    2. login: "juliannoble2"
    3. mimetype: "text/plain"
  6. Ticket change [f638f27bea] (rid 217513) by griffin on 2023-08-29 02:01:23:

    1. icomment:
      Fix on branch [bug-cd61f085da]. 
      Included a change to disallow 123_._456, i.e., underscore adjacent to '.'.  
      Or, in other words, there must be a digit on both sides of an underscore.
      I need to clean up the error messages. 
      They don't all accurately reflect the true error.
      
    2. login: "griffin"
    3. mimetype: "text/x-fossil-plain"
  7. Ticket change [3d7e9c18df] (rid 217519) by juliannoble2 on 2023-08-29 14:30:38:

    1. icomment:
      I checked out branch bug-cd61f085da
      It seems more robust.
      
      I see you disallowed multiple underscores in a row. I confess to being a little disappointed - as my concerns about the syntax leaking probably don't distinguish between 1_000  vs 'non standard' groupings like 10_00  or novel spacings like 10___00.  If it's going to have any underscores the care has to be taken anyway - and I actually liked the less conservative approach in that minor regard.
      The comments about creative freedom on the core mailing list were interesting.
      
      e.g the following was mentioned:
      #          foo   bar   snafu
      set list {
                 54_____6_____000
                 42_____9_____001
      }
      
      In combination with DKFs tip 677  https://core.tcl-lang.org/tips/doc/trunk/tip/677.md
      , giving some scoped immutability to variables - I thought this would be very nice to retain.
      
      Anyway - perhaps implementation issues are the decider.
      
      I do feel however there is a remaining inconsistency that may cause errors when editing code:
      
      % expr 2.1e_2
      210.0
      % expr 2.1e_+2
      invalid character "."
      in expression "2.1e_+2"
      %
      % expr 2.1e+_2
      210.0
      
      If the underscore is allowed after the e when there is no +/- then it should be allowed in the presence of the + or - too - otherwise someone simply editing to throw in a + or - of an already underscored value will be surprised.
      
    2. login: "juliannoble2"
    3. mimetype: "text/plain"
  8. Ticket change [6a95f9c177] (rid 217520) by juliannoble2 on 2023-08-29 14:36:55:

    1. icomment:
      also - the fix
      disallows  1_._1  
      disallows 1_.1
      allows 1._1
      
      I think that 3rd case should be disallowed.
      
    2. login: "juliannoble2"
    3. mimetype: "text/plain"
  9. Ticket change [090de37c09] (rid 217521) by juliannoble2 on 2023-08-29 16:18:17:

    1. icomment:
      There's another edge case around scientific notation.
      Underscore seems to be allowed before, or after the e but not both.
      
      Perhaps the rule should be underscores between digits or after a radix specifier 0x etc  - but not next to the e (or +/-) in sci notation.
      Your insights into what makes implementation less curly may come up with a different rule - but hopefully something consistent and easily understandable is practical.
      
      % expr 1.0e_2
      100.0
      % expr 1.0_e2
      100.0
      % expr 1.0_e_2
      invalid character "."
      in expression "1.0_e_2"
      
    2. login: "juliannoble2"
    3. mimetype: "text/plain"
  10. Ticket change [f77e0fdcd8] (rid 217522) by juliannoble2 on 2023-08-29 17:47:55:

    1. icomment:
      Just as a further reason why I think the rules for underscores need to be very simple and understandable and why the underscores shouldn't be allowed adjacent to e|E:
      
      
      #1
      % set x 1.e_2
      1.e_2
      % expr {$x < 100}
      0
      
      #2
      % set x 1.e_+2
      1.e_+2
      % expr {$x < 100}
      1
      
      
      #2 gets us right back to accidental string comparison (though this example is just an artifact of the current state of the fix)
      
      if you allow 1.0_e2  but then disallow 1._e2  to be consistent with disallowing 1._1 & 1_.1 then this also risks accidental string comparison for those assuming 'before e|E is always ok'.
      
      If the current fix allowing 1._1 is intentional - then the risk is misinterpretation of the rules to think 1_._1 and/or 1_.1 are ok - as well as the previously mentioned surprise for those splitting on the dot and getting a string in part b even after having already filtered out sci notation.
      
      By disallowing anywhere but in between digits and perhaps after radix spec - it would seem to alleviate this risk.
      
    2. login: "juliannoble2"
    3. mimetype: "text/plain"
  11. Ticket change [1a056e905a] (rid 217539) by juliannoble2 on 2023-08-30 12:33:52:

    1. icomment:
      From playing with this bugfix version - it's become clearer to me that the bigger problem is minor 'numeric whitespace' editing (i.e changing internal underscores)
      causing accidental string comparisons in later expressions which could go unnoticed depending on the data.
      
      Because 1.e2  is legitimate notation - rules around underscore not being allowed near the . or the e or the +|- in scientific notation become too complex and prone to accidental string comparison as in my previous example.
      
      My concern about people splitting on .  in 0_._0  (or on eE )  are less important - and best addressed by documenting something along the lines of: Use 'string map {_ ""} $num'  prior to doing any string analysis of a number or its components.
      
      I think the initial version had this right in being lenient about internal underscores  - except for the bug reported in this ticket.
      
    2. login: "juliannoble2"
    3. mimetype: "text/plain"
  12. Ticket change [582d416722] (rid 217632) by juliannoble2 on 2023-08-31 08:00:13:

    1. icomment:
      Tested checkin  9a2043019b
      
      Your new rule - stated in the comments as 'for an integer value'; essentially that a numeric whitespace must begin and end with a digit from the relevant base ; is I think a nice clear simple rule. That 0x_a1 0b_1 etc are now disallowed seems reasonable and probably makes code analysis/review easier.
      
      The current state of the fix seems not quite there as it still disallows
      0.000_001 
      0.000_001e0_2
      but allows
      0.000001e0_2
      
      I presume the same rule goes for the RHS of floats and these should all be allowed.
      
    2. login: "juliannoble2"
    3. mimetype: "text/plain"
  13. Ticket change [fd7c894e6c] (rid 217655) by griffin on 2023-09-01 03:41:20:

    1. icomment:
      All the reported failures have been fixed, as well as others I've discovered. This fix is on branch [bug-cd61f085da](timeline?r=bug-cd61f085da)
      
      The implementation reflects the following description of numeric white-space:
      
      The definition for numeric white-space is simplified to: 
         1 or more '`_`' characters may be placed between digits only.
      
      Numeric white-space cannot be:
      
      - at the beginning of a number
      
      - before or after a '`+`' or '`-`'
      
      - before or after a decimal point '`.`'
      
      - before or after an exponent '`e`' or '`E`' symbol
      
      - before, after, or in between a base specifier `0b`, `0o`, `0d`, or `0x`
      
      Legal examples:  
      
      ```
          0x1_2__34___56
          2_0.3_4e+1_5
      ```
      
      Illegal examples: 
      
      ```
          _0_x_123456_
          _20_._34_e_+_15_
      ```
      
    2. login: "griffin"
    3. mimetype: "text/x-markdown"
  14. Ticket change [37176f26ed] (rid 217656) by juliannoble2 on 2023-09-01 06:41:53:

    1. icomment:
      Only problem I could find is octal with 2 or more underscores in a row gives an (invalid octal number?) error.
      
    2. login: "juliannoble2"
    3. mimetype: "text/plain"
  15. Ticket change [a055e0a9b4] (rid 217663) by juliannoble2 on 2023-09-01 19:32:57:

    1. icomment:
      Nice tight spec. This monkey-powered keyboard couldn't break it.
      
    2. login: "juliannoble2"
    3. mimetype: "text/plain"
  16. Ticket change [6f52983718] (rid 217666) by griffin on 2023-09-01 20:56:55:

    1. closedate changed to: "2460189.37286939"
    2. closer changed to: "griffin"
    3. icomment: "Fixed with 5fea51151f"
    4. login: "griffin"
    5. mimetype: "text/x-fossil-plain"
    6. status changed to: "Closed"