[Mono-list] MonoBASIC bug reporting

Peter Gulder peter.gulder@zoznam.sk
Sun, 16 Nov 2003 17:00:20 +0100

This is a multi-part message in MIME format.

Content-Type: text/plain;
Content-Transfer-Encoding: 7bit


is it possible to report bugs found in MonoBasic to Bugzilla?
I could not find direct link on page http://www.go-mono.com/bugs.html

Here is the bug I found:
OS: Windows XP SP1,
Mono version: 0.28
Title: MBas freezes when trying to compile simple QuickSort example from
MSDNAA (http://www.msdnaa.net/) and consumes 100% of CPU
Command Line: mbas.bat QuickSort2.vb --timestamp

[00:172] Loading references
[00:047] References loaded
[00:015] Initializing Core Types
[00:141]    Core Types done
[00:000] Resolving tree
[00:016] Populate tree
[00:125] Emitting code

Here Mbas freezes for long time (I was waiting 10 minutes, when I
stopped it) and consumes 100% of CPU.
Simple programs are compiled correctly, for example, this works:

Imports System

Module t0
    Sub Main()
    End Sub
End Module

Peter Gulder

Content-Type: text/plain;
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;

'  QuickSort VB.NET Sample Application
'  Copyright =A92001-2002 Microsoft Corporation. All rights reserved.
'  MSDN ACADEMIC ALLIANCE [http://www.msdnaa.net/]
'  This sample is part of a vast collection of resources we developed =
'  faculty members in K-12 and higher education. Visit the MSDN AA web =
site for more!
'  The source code is provided "as is" without warranty.

' Import namespaces
Imports System
Imports System.Collections
Imports System.IO
Imports Microsoft.VisualBasic

' Declare application class
Module QuickSortApp

    ' Application initialization
    Sub Main()

        'Print startup banner
        Console.WriteLine("QuickSort VB.NET Sample Application")
        Console.WriteLine("Copyright (c)2001-2002 Microsoft Corporation. =
All rights reserved.")
        Console.WriteLine("MSDN ACADEMIC ALLIANCE =

        ' Describe program function
        Console.WriteLine("This example demonstrates the QuickSort =
algorithm by reading an input file,")
        Console.WriteLine("sorting its contents, and writing them to a =
new file.")

        ' Prompt user for filenames
        Dim szSrcFile, szDestFile As String
        Console.Write("Source: ")
        szSrcFile =3D Console.ReadLine()
        Console.Write("Output: ")
        szDestFile =3D Console.ReadLine()

        ' Read contents of source file
        Dim szSrcLine As String
        Dim szContents As ArrayList
        Dim fsInput As FileStream
        Dim srInput As StreamReader
        szContents =3D New ArrayList()
        fsInput =3D New FileStream(szSrcFile, FileMode.Open, =
        srInput =3D New StreamReader(fsInput)
        szSrcLine =3D srInput.ReadLine()
        While Not IsNothing(szSrcLine)
            ' Append to array
            szSrcLine =3D srInput.ReadLine()
        End While

        ' Pass to QuickSort function
        QuickSort(szContents, 0, szContents.Count - 1)

        ' Write sorted lines
        Dim fsOutput As FileStream
        Dim srOutput As StreamWriter
        Dim nIndex As Integer
        fsOutput =3D New FileStream(szDestFile, FileMode.Create, =
        srOutput =3D New StreamWriter(fsOutput)
        For nIndex =3D 0 To szContents.Count - 1
            ' Write line to output file
        Next nIndex

        ' Report program success
        Console.WriteLine("The sorted lines have been written to the =
output file.")

    End Sub

    ' QuickSort implementation
    Sub QuickSort(ByRef szArray As ArrayList, ByVal nLower As Integer, =
ByVal nUpper As Integer)

        ' Check for non-base case
        If nLower < nUpper Then
            ' Split and sort partitions
            Dim nSplit As Integer
            nSplit =3D Partition(szArray, nLower, nUpper)
            QuickSort(szArray, nLower, nSplit - 1)
            QuickSort(szArray, nSplit + 1, nUpper)
        End If

    End Sub

    ' QuickSort partition implementation
    Function Partition(ByRef szArray As ArrayList, ByVal nLower As =
Integer, ByVal nUpper As Integer) As Integer

        ' Pivot with first element
        Dim szPivot As String
        Dim nLeft, nRight As Integer
        nLeft =3D nLower + 1
        szPivot =3D szArray(nLower)
        nRight =3D nUpper

        ' Partition array elements
        Dim szSwap As String
        While nLeft <=3D nRight

            ' Find item out of place
            While nLeft <=3D nRight
                If szArray(nLeft).CompareTo(szPivot) > 0 Then Exit While
                nLeft =3D nLeft + 1
            End While
            While nLeft <=3D nRight
                If szArray(nRight).CompareTo(szPivot) <=3D 0 Then Exit =
                nRight =3D nRight - 1
            End While

            ' Swap values if necessary
            If (nLeft < nRight) Then
                szSwap =3D szArray(nLeft)
                szArray(nLeft) =3D szArray(nRight)
                szArray(nRight) =3D szSwap
                nLeft =3D nLeft + 1
                nRight =3D nRight - 1
            End If

        End While

        ' Move pivot element
        szSwap =3D szArray(nLower)
        szArray(nLower) =3D szArray(nRight)
        szArray(nRight) =3D szSwap
        Return nRight

    End Function

End Module