Skip to content
Tcl Source Code History Of Ticket 96551aca55
Login

History Of Ticket 96551aca55

Artifacts Associated With Ticket 96551aca55

  1. Ticket change [a021dcee10] (rid 213604) by chrstphrchvz on 2023-04-22 07:23:48:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-wiki"
    4. comment initialized to:
      Not aware exactly what Tcl code triggers this, but it appears at the beginning of output from <tt>tcltest</tt> during <tt>make test</tt>:
      
      <blockquote><pre>
      <b>generic/tclOOMethod.c:1108:2: <span style="color:firebrick">runtime error:</span> applying zero offset to null pointer</b>
      </pre></blockquote>
      
      
      Something like the following is needed (<tt>var</tt> should also be parenthesized to avoid surprises):
      
      <blockquote><pre>
      --- generic/tclOOInt.h.orig
      +++ generic/tclOOInt.h
      @@ -594,7 +594,7 @@ MODULE_SCOPE void   TclOOSetupVariableResolver(Tcl_Namespace *nsPtr);
        */
      &nbsp;
       #define FOREACH_STRUCT(var,ary) \
      <span style="color:firebrick">-    for(i=0 ; var=&((ary).list[i]), i<(ary).num; i++)</span>
      <span style="color:green">+    for(i=0 ; (var)=((ary).list ? &((ary).list[i]) : NULL), i<(ary).num; i++)</span>
      &nbsp;
       /*
        * Convenience macros for iterating through hash tables. FOREACH_HASH_DECLS
      </pre></blockquote>
      
      <pre>
      </pre>
      
    5. foundin initialized to: "core-8-branch"
    6. is_private initialized to: "0"
    7. login: "chrstphrchvz"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "6133eb3026f9b10aa9b7b48da92ae2834fc225b0"
    10. resolution initialized to: "None"
    11. severity initialized to: "Minor"
    12. status initialized to: "Open"
    13. submitter initialized to: "chrstphrchvz"
    14. subsystem initialized to: "35. TclOO Package"
    15. title initialized to:
      Avoid pointer arithmetic with NULL in FOREACH_STRUCT()
      
    16. type initialized to: "Patch"
  2. Ticket change [bf1787bfdb] (rid 213605) by chrstphrchvz on 2023-04-22 07:32:11:

    1. comment changed to:
      Not aware exactly what Tcl code triggers this, but this <tt>-fsanitize=pointer-overflow</tt> error is emitted at the beginning of output from <tt>tcltest</tt> during <tt>make test</tt>:
      
      <blockquote><pre>
      <b>generic/tclOOMethod.c:1108:2: <span style="color:firebrick">runtime error:</span> applying zero offset to null pointer</b>
      </pre></blockquote>
      
      
      Something like the following is needed (<tt>var</tt> should also be parenthesized to avoid surprises):
      
      <blockquote><pre>
      --- generic/tclOOInt.h.orig
      +++ generic/tclOOInt.h
      @@ -594,7 +594,7 @@ MODULE_SCOPE void   TclOOSetupVariableResolver(Tcl_Namespace *nsPtr);
        */
      &nbsp;
       #define FOREACH_STRUCT(var,ary) \
      <span style="color:firebrick">-    for(i=0 ; var=&((ary).list[i]), i<(ary).num; i++)</span>
      <span style="color:green">+    for(i=0 ; (var)=((ary).list ? &((ary).list[i]) : NULL), i<(ary).num; i++)</span>
      &nbsp;
       /*
        * Convenience macros for iterating through hash tables. FOREACH_HASH_DECLS
      </pre></blockquote>
      
      <pre>
      </pre>
      
    2. login: "chrstphrchvz"
    3. mimetype: "text/plain"
  3. Ticket change [9223bfa095] (rid 213637) by jan.nijtmans on 2023-04-22 18:08:58:

    1. assignee changed to: "jan.nijtmans"
    2. icomment:
      I have doubts on this one. From what I understand from the code "(ary).list" should never be NULL, so if it's NULL somewhere that sounds as a bug. Your fix just hides this bug, so: Yes I would like to know where this is triggered.
      
    3. login: "jan.nijtmans"
    4. mimetype: "text/x-fossil-wiki"
  4. Ticket change [508cd8ea6c] (rid 213642) by chrstphrchvz on 2023-04-22 21:37:53:

    1. comment changed to:
      Not aware exactly what Tcl code triggers this, but this <tt>-fsanitize=pointer-overflow</tt> error is emitted at the beginning of output from <s><tt>tcltest</tt> during <tt>make test</tt></s> <tt>tclsh</tt>:
      
      <blockquote><pre>
      <b>generic/tclOOMethod.c:1108:2: <span style="color:firebrick">runtime error:</span> applying zero offset to null pointer</b>
      </pre></blockquote>
      
      
      Something like the following is needed (<tt>var</tt> should also be parenthesized to avoid surprises):
      
      <blockquote><pre>
      --- generic/tclOOInt.h.orig
      +++ generic/tclOOInt.h
      @@ -594,7 +594,7 @@ MODULE_SCOPE void   TclOOSetupVariableResolver(Tcl_Namespace *nsPtr);
        */
      &nbsp;
       #define FOREACH_STRUCT(var,ary) \
      <span style="color:firebrick">-    for(i=0 ; var=&((ary).list[i]), i<(ary).num; i++)</span>
      <span style="color:green">+    for(i=0 ; (var)=((ary).list ? &((ary).list[i]) : NULL), i<(ary).num; i++)</span>
      &nbsp;
       /*
        * Convenience macros for iterating through hash tables. FOREACH_HASH_DECLS
      </pre></blockquote>
      
      <pre>
      </pre>
      
    2. icomment:
      This happens somewhere deep within <tt>TclOOInit()</tt> (so any time an interpreter is created rather than just <tt>tcltest</tt>), during tclOOScript.tcl:416 ("<tt>superclass class</tt>" while in "<tt>class create singleton …</tt>").
      
    3. login: "chrstphrchvz"
    4. mimetype: "text/x-fossil-wiki"
  5. Ticket change [d6b60cc152] (rid 214695) by chrstphrchvz on 2023-05-08 00:35:41:

    1. icomment:
      <blockquote>From what I understand from the code "(ary).list" should never be NULL…</blockquote>
      
      I believe the comment for <tt>FOREACH_STRUCT()</tt> is pointing out how, unlike for the <tt>FOREACH()</tt> macro, <tt>(ary).list<b>&#91;i&#93;</b></tt> is never <tt>NULL</tt>; I do not think it refers to whether <tt>(ary).list</tt> is <tt>NULL</tt>.
      
      I really am not familiar with TclOO, but what I am finding is that <tt>(ary).list == NULL</tt> is valid for <tt>(ary).num == 0</tt>. The specific error at tclOOMethod.c:1108 occurs whenever a class does not have any private variables.
      
    2. login: "chrstphrchvz"
    3. mimetype: "text/x-fossil-wiki"
  6. Ticket change [cdd1634b39] (rid 214699) by jan.nijtmans on 2023-05-08 09:37:18:

    1. icomment:
      Many thanks for this explanation. It makes sense!
      
      How about [0a39ff278486cb6a|this] then?
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  7. Ticket change [c1e98215b1] (rid 214703) by chrstphrchvz on 2023-05-08 13:12:39:

    1. icomment:
      I do think [0a39ff278486] is better than my initial suggestion (as long as others understand it and are not tempted to undo it), however it looks like there is dependency on the (undocumented) side effect of the macro leaving <tt>i == ((ary).num &lt; 0 ? 0 : (ary).num)</tt> in <tt>InstallPrivateVariableMapping()</tt> (tclOODefineCmds.c:552), <tt>TclOOReleaseClassContents()</tt> (tclOO.c:1089), and <tt>ObjectNamespaceDeleted()</tt> (tclOO.c:1252),
      
    2. login: "chrstphrchvz"
    3. mimetype: "text/x-fossil-wiki"
  8. Ticket change [3a3cee6ee4] (rid 214704) by chrstphrchvz on 2023-05-08 13:37:17:

    1. icomment:
      Maybe something like this will work:
      <pre>
      #define FOREACH_STRUCT(var,ary) \
          if (i=0, (ary).num&gt;0) for(; var=&amp;((ary).list&#91;i&#93;), i&lt;(ary).num; i++)
      </pre>
      
    2. login: "chrstphrchvz"
    3. mimetype: "text/x-fossil-wiki"
  9. Ticket change [c664fae551] (rid 214707) by jan.nijtmans on 2023-05-08 13:44:42:

    1. icomment:
      Indeed! You are fully right! Better version [72b13bcbe81628cd|here]
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  10. Ticket change [547acaadd3] (rid 214708) by jan.nijtmans on 2023-05-08 13:51:48:

    1. icomment:
      > Maybe something like this will work:
      
      I didn't see this suggestion until after I committed my "Better version". I like your version too
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  11. Ticket change [b6d755203e] (rid 214710) by jan.nijtmans on 2023-05-08 14:10:25:

    1. icomment:
      Thinking more about it: Your solution is a single C-statement, which has less chance for side-effects than mine. So, I'll follow your suggestion. Thanks!
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
  12. Ticket change [eb888a436b] (rid 214742) by jan.nijtmans on 2023-05-09 15:00:37:

    1. closedate changed to: "2460074.12543735"
    2. closer changed to: "jan.nijtmans"
    3. icomment: "Now merged to core-8-branch and trunk"
    4. login: "jan.nijtmans"
    5. mimetype: "text/x-fossil-wiki"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"