[Mono-bugs] [Bug 75733][Nor] Changed - The io-layer sometimes creates handles with a value of NULL
bugzilla-daemon at bugzilla.ximian.com
bugzilla-daemon at bugzilla.ximian.com
Sat Oct 7 11:02:25 EDT 2006
Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.
Changed by miguel at ximian.com.
http://bugzilla.ximian.com/show_bug.cgi?id=75733
--- shadow/75733 2005-08-23 13:35:59.000000000 -0400
+++ shadow/75733.tmp.7399 2006-10-07 11:02:25.000000000 -0400
@@ -40,6 +40,61 @@
Alternatively, we could check if the return is zero, if so we dup the
fd and close the zero fd.
A hack
+
+------- Additional Comments From miguel at ximian.com 2006-10-07 11:02 -------
+I tried the approach I suggested, but it breaks when we have to cope
+with the real handle "fd 0" (for Console), and sprinkling ifs
+everywhere to cope with the 0 case sounds like a bad idea, and it
+woudld be easy to introduce this error in future uses of the code if
+we are not careful.
+
+I saw that the code in process.c no longer calls CloseHandle if the
+value is NULL.
+
+But I think the real fix is not to set the value to NULL, but to
+initialize the value of hThread to INVALID_HANDLE_VALUE (-1), which
+btw, we do not seem to use at all in Mono's io-layer, so this value
+might be fine.
+
+The following patch implements this:
+
+Index: handles.c
+===================================================================
+--- handles.c (revision 66360)
++++ handles.c (working copy)
+@@ -699,7 +699,7 @@
+ gboolean search_shared)
+ {
+ struct _WapiHandleUnshared *handle_data = NULL;
+- struct _WapiHandleShared *shared;
++ struct _WapiHandleShared *shared = NULL;
+ gpointer ret = NULL;
+ guint32 i, k;
+ gboolean found = FALSE;
+@@ -1222,6 +1222,10 @@
+ return(FALSE);
+ }
+ }
++ if (handle == _WAPI_HANDLE_INVALID){
++ SetLastError (ERROR_INVALID_PARAMETER);
++ return(FALSE);
++ }
+
+ _wapi_handle_unref (handle);
+
+Index: processes.c
+===================================================================
+--- processes.c (revision 66360)
++++ processes.c (working copy)
+@@ -818,7 +818,7 @@
+ /* FIXME: we might need to handle the thread info some
+ * day
+ */
+- process_info->hThread = NULL;
++ process_info->hThread = INVALID_HANDLE_VALUE;
+ process_info->dwThreadId = 0;
+ }
+
More information about the mono-bugs
mailing list