Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 1be3cc5a99fb4dc0763efb90792dbe1ce6f653d62c8e1fb871a73f3c83f75a42
Ticket: bd94500678e837d7ed50cf6d5000df8f38cd5e39
SEGFAULT by conversion of unicode (out of BMP) to byte-array.
User & Date: sebres on 2019-02-06 13:34:29
Changes

  1. icomment:
    Just to explain on the real example what I mean:
    
    [https://github.com/AltSysrq/Abendstern/blob/106e1ad2457f7bfd90080eecf49a33f6079f8e1e/src/graphics/font.cxx#L101-L102|github/Abendstern/.../graphics/font.cxx#L101-L102]
    
    <code><pre>
    61   while (*str) {
    62     if ... {
             // ... long block here ...
    100    } else {
    101      Tcl_UniChar ch;
    102      str += Tcl_UtfToUniChar(str, &ch);
    103      ch &= 0xFFFF;
    104      if (!hasLoaded[ch]) const_cast<Font*>(this)->renderCharacter(ch);
             // ...
    107    }
    108  }
    </pre></code>
    And I mean not the modification of "ch" (in line 103), which still looks safe but could be affected later by some high surrogates (larger as word)... 
    
    But as you can see, the the variable "ch" is local-scope variable here (let alone it is not initialized, but has the existence in this scope only), so if the compiler optimizes this to use the reserverd stack block (for some other variables/calls between 61-101), the value of this may be overwritten, so you will get BO and/or endless cycle.
    
    And I found it immediatelly as I just started my search (as I had small pause only), so I would not exclude thousands of modules/apps could be affected similar ways.
    
  2. login: "sebres"
  3. mimetype: "text/x-fossil-wiki"