<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    I just used a goto in a patch i submitted tonight too:  I enabled
    the ability of Win32 to send an idle event message when the app goes
    idle.  Previously, Win32 mono was not doing that.<br>
    <br>
    Sent on github, if someone wants to review.  I tested relevant code
    on relevant platforms.<br>
    <br>
    -Rob<br>
    <br>
    On 06/11/2012 10:14 PM, Steven Boswell II wrote:
    <blockquote
      cite="mid:1339467259.37073.YahooMailNeo@web160406.mail.bf1.yahoo.com"
      type="cite">
      <div style="color:#000; background-color:#fff; font-family:times
        new roman, new york, times, serif;font-size:12pt">
        <div><span>Since no one seems inclined to look at this bug,
            here's my proposed fix.</span></div>
        <div><span>The problem seems to be
            that ves_icall_System_IO_MonoIO_GetFileSystemEntries() can
            return NULL without setting an error.</span></div>
        <div><span>So I rewrote the code to create an empty string-array
            in that case.</span></div>
        <div><span>My code uses the dreaded "goto", but IMHO that's no
            worse than a return statement in the middle of a function.
             Besides, in assembly language, all we have is goto :-)</span></div>
        <div><span><br>
          </span></div>
        <div><span>Steven Boswell</span></div>
        <div><br>
        </div>
        <div style="font-size: 12pt; font-family: 'times new roman',
          'new york', times, serif; ">
          <div style="font-size: 12pt; font-family: 'times new roman',
            'new york', times, serif; ">
            <div dir="ltr"> <font face="Arial" size="2">
                <hr size="1"> <b><span style="font-weight:bold;">From:</span></b>
                Steven Boswell II <a class="moz-txt-link-rfc2396E" href="mailto:ulatekh@yahoo.com"><ulatekh@yahoo.com></a><br>
                <b><span style="font-weight: bold;">To:</span></b>
                <a class="moz-txt-link-rfc2396E" href="mailto:mono-devel-list@lists.ximian.com">"mono-devel-list@lists.ximian.com"</a>
                <a class="moz-txt-link-rfc2396E" href="mailto:mono-devel-list@lists.ximian.com"><mono-devel-list@lists.ximian.com></a> <br>
                <b><span style="font-weight: bold;">Sent:</span></b>
                Friday, June 8, 2012 5:43 PM<br>
                <b><span style="font-weight: bold;">Subject:</span></b>
                [Mono-dev] GetFileSystemEntries() can return null, but
                very few null checks<br>
              </font> </div>
            <br>
            <div id="yiv1324997790">
              <div>
                <div style="color: rgb(0, 0, 0); background-color:
                  rgb(255, 255, 255); font-size: 12pt; font-family:
                  'times new roman', 'new york', times, serif; ">
                  <div id="yiv1324997790">
                    <div>
                      <div style="background-color: rgb(255, 255, 255);
                        font-family: times, serif; ">
                        <div
                          id="yiv1324997790yui_3_2_0_19_133918270620940"
                          style="color: rgb(0, 0, 0); font-size: 12pt;
                          font-family: times, serif; ">Today, rather
                          randomly, I got an unhandled
                          NullReferenceException in
                          mcs/class/System/System.IO/DefaultWatcher.cs
                          at line 221 -- "files" was null.  All the
                          places that "files" gets set can't be null,
                          except for the one on line 204, a call to
                          Directory.GetFileSystemEntries().  That led to
                          mcs/class/corlib/System.IO/Directory.cs line
                          497, which led to <span
                            style="font-size:12pt;">mcs/class/</span><span
                            style="font-size:12pt;">corlib/System.IO/MonoIO.cs
                            line 177, which led to a C function called
                            ves_icall_System_IO_MonoIO_GetFileSystemEntries(),
                            which starts at line 319 of
                            mono/metadata/file-io.c .  That function can
                            return null in several different ways.</span></div>
                        <div
                          id="yiv1324997790yui_3_2_0_19_133918270620940"
                          style="color: rgb(0, 0, 0); font-size: 12pt;
                          font-family: times, serif; "><span
                            style="font-size:12pt;"><br>
                          </span></div>
                        <div style="color: rgb(0, 0, 0); font-size:
                          12pt; font-family: times, serif; ">Looking
                          around, this seems to be a general problem...</div>
                        <div style="color: rgb(0, 0, 0); font-size:
                          12pt; font-family: times, serif; "><br>
                        </div>
                        <div>
                          <div>Files that call GetFileSystemEntries()
                            and check for null:</div>
                          <div>mcs/class/System.Web/System.Web.Hosting/ApplicationHost.cs</div>
                          <div><br>
                          </div>
                          <div>Files that call GetFileSystemEntries()
                            without checking for null:</div>
                          <div>mcs/class/Compat.ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib/Tar/TarEntry.cs</div>
                          <div>mcs/class/ICSharpCode.SharpZipLib/ICSharpCode.SharpZipLib/Tar/TarEntry.cs</div>
                          <div>mcs/class/Microsoft.Build.Utilities/Mono.XBuild.Utilities/MSBuildUtils.cs</div>
                          <div>mcs/class/Mono.Posix/Mono.Unix/UnixDirectoryInfo.cs</div>
                          <div>mcs/class/System/System.IO/DefaultWatcher.cs</div>
                          <div>mcs/tools/macpack/MacPack.cs</div>
                          <div>mcs/tools/monodoc/Lucene.Net/Lucene.Net/SupportClass.cs</div>
                          <div><br>
                          </div>
                          <div>Files with a GetFileSystemEntries() that
                            can return null:</div>
                          <div>mcs/class/corlib/Linux/Linux.cs</div>
                          <div>mono/metadata/file-io.c</div>
                          <div><br>
                          </div>
                          <div>If fixing this is as simple as adding
                            null checks to the affected areas, I can
                            crank that out and submit a patch.
                             Otherwise, someone more knowledgeable than
                            me needs to look into this.</div>
                          <div><br>
                          </div>
                          <div>I don't see any bug reports in either <a
                              moz-do-not-send="true" target="_blank"
                              href="http://bugzilla.novell.com">bugzilla.novell.com</a>
                            or <a moz-do-not-send="true"
                              target="_blank"
                              href="http://bugzilla.xamarin.com">bugzilla.xamarin.com</a>
                            about this issue.  I searched "Mono class
                            libraries" and "Mono runtime".  There were a
                            few other issues related
                            to GetFileSystemEntries(), but none that
                            sounded like this.  So I filed
                            one... <a class="moz-txt-link-freetext" href="https://bugzilla.xamarin.com/show_bug.cgi?id=5591">https://bugzilla.xamarin.com/show_bug.cgi?id=5591</a>
                            .</div>
                          <div><br>
                          </div>
                          <div>Steven Boswell</div>
                          <div><br>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
            <br>
            _______________________________________________<br>
            Mono-devel-list mailing list<br>
            <a moz-do-not-send="true"
              ymailto="mailto:Mono-devel-list@lists.ximian.com"
              href="mailto:Mono-devel-list@lists.ximian.com">Mono-devel-list@lists.ximian.com</a><br>
            <a moz-do-not-send="true"
              href="http://lists.ximian.com/mailman/listinfo/mono-devel-list"
              target="_blank">http://lists.ximian.com/mailman/listinfo/mono-devel-list</a><br>
            <br>
            <br>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Mono-devel-list mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Mono-devel-list@lists.ximian.com">Mono-devel-list@lists.ximian.com</a>
<a class="moz-txt-link-freetext" href="http://lists.ximian.com/mailman/listinfo/mono-devel-list">http://lists.ximian.com/mailman/listinfo/mono-devel-list</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>