[Mono-devel-list] file-io.c question and help requested

Derek McUmber derek.mcumber at datamtnsol.com
Wed Feb 18 11:19:47 EST 2004

Hi all:

I am looking for some insight on a mono problem I have in

I have been working on a port of mono to Win98 and have
only a couple dozen changes that will need to be inserted
into the build.  I will do a writeup of those changes and
ask for help once I have it working.

My current issue is with the w32API call in gcc called

The following code will crash a Win95/98 machine by
hanging the kernel (so I assume) on the second execution
of the .exe.  (doesn't seem to matter how many times I loop.)

using System;
using System.IO;
class X

	public static void Main ()
		string path = "C:\\anyfile.txt";

		for (int i = 0; i < 1000; i++) {
			if (!File.Exists(path)) {
				Console.WriteLine("Not found.");
			} else {

It hangs the OS at the internal call GetFileAttributes

I notice in a debug version of mono that the
output from file-io.c looks like this:

	Calling GetFileAttributes "anyfile.txt"
	Calling GetFileAttributes "anyfile.txt"
	Returned from GetFileAttributes status: 1
	Returned from GetFileAttributes status: 1
	Error code from GetFileAttributes status: 0
	Error code from GetFileAttributes status: 0

At this point, the machine stops and I need to power down
and reboot.

A.  Could mono.exe be unloading the kernal upon exit of the app?
A.Test:  I try to LoadLibrary("Kernal32.dll") before the
GetFileAttributes call, every time, and I get the error code
1157 (dll_not_found) and I still hang.

B.  Win98 kernel is not handling threading/context switching

One guess is that this windows library isn't completely threadsafe on
Win98 since the same code executes fine on WinXP/2000.

Should I find a way to block mono for this call on Win98
(a few in file-io.c) so that it must not allow this behavior?

C.  On the web, someone on the web changed their implementation
of file existence to use a different api call (FileNext?)
and the problem went away.....  Should I try this and would we
want to change mono?

I know that a change like this will have implications for the
code base and want to find an elegant solution.

Thanks in advance,


More information about the Mono-devel-list mailing list