Author: ion
Date: Wed Jun 14 08:02:02 2006
New Revision: 22345
URL:
http://svn.reactos.ru/svn/reactos?rev=22345&view=rev
Log:
- Fix some referencing/bugs in Ob functions that I wrote which were known fixmes.
- Remove every instance of ObDereferenceObject after an ObInsertObject that I could find.
This temporarily will make the object leaks even worse, but it's better to increase
leaks and then fix the ref bug, then to decrease references while missing spots that
forgot to reference them (you'd end up with hard to debug randomly dying objects).
Modified:
trunk/reactos/ntoskrnl/cm/ntfunc.c
trunk/reactos/ntoskrnl/ex/event.c
trunk/reactos/ntoskrnl/ex/evtpair.c
trunk/reactos/ntoskrnl/ex/mutant.c
trunk/reactos/ntoskrnl/ex/sem.c
trunk/reactos/ntoskrnl/io/device.c
trunk/reactos/ntoskrnl/io/iocomp.c
trunk/reactos/ntoskrnl/lpc/connect.c
trunk/reactos/ntoskrnl/lpc/create.c
trunk/reactos/ntoskrnl/mm/section.c
trunk/reactos/ntoskrnl/ob/obdir.c
trunk/reactos/ntoskrnl/ob/obhandle.c
trunk/reactos/ntoskrnl/ob/obname.c
trunk/reactos/ntoskrnl/ob/obref.c
trunk/reactos/ntoskrnl/ob/symlink.c
trunk/reactos/ntoskrnl/ps/thread.c
trunk/reactos/ntoskrnl/se/token.c
Modified: trunk/reactos/ntoskrnl/cm/ntfunc.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/cm/ntfunc.c?rev=22…
==============================================================================
--- trunk/reactos/ntoskrnl/cm/ntfunc.c (original)
+++ trunk/reactos/ntoskrnl/cm/ntfunc.c Wed Jun 14 08:02:02 2006
@@ -573,7 +573,7 @@
}
if (ObjectName.Buffer) ObpReleaseCapturedName(&ObjectName);
if (FreeRemainingPath) RtlFreeUnicodeString(&RemainingPath);
- if (Object != NULL) ObDereferenceObject(Object);
+ //if (Object != NULL) ObDereferenceObject(Object);
return Status;
}
Modified: trunk/reactos/ntoskrnl/ex/event.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/ex/event.c?rev=223…
==============================================================================
--- trunk/reactos/ntoskrnl/ex/event.c (original)
+++ trunk/reactos/ntoskrnl/ex/event.c Wed Jun 14 08:02:02 2006
@@ -151,7 +151,6 @@
0,
NULL,
&hEvent);
- ObDereferenceObject(Event);
/* Check for success */
if(NT_SUCCESS(Status))
Modified: trunk/reactos/ntoskrnl/ex/evtpair.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/ex/evtpair.c?rev=2…
==============================================================================
--- trunk/reactos/ntoskrnl/ex/evtpair.c (original)
+++ trunk/reactos/ntoskrnl/ex/evtpair.c Wed Jun 14 08:02:02 2006
@@ -110,7 +110,6 @@
0,
NULL,
&hEventPair);
- ObDereferenceObject(EventPair);
/* Check for success and return handle */
if(NT_SUCCESS(Status))
Modified: trunk/reactos/ntoskrnl/ex/mutant.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/ex/mutant.c?rev=22…
==============================================================================
--- trunk/reactos/ntoskrnl/ex/mutant.c (original)
+++ trunk/reactos/ntoskrnl/ex/mutant.c Wed Jun 14 08:02:02 2006
@@ -133,7 +133,6 @@
0,
NULL,
&hMutant);
- ObDereferenceObject(Mutant);
/* Check for success */
if(NT_SUCCESS(Status))
Modified: trunk/reactos/ntoskrnl/ex/sem.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/ex/sem.c?rev=22345…
==============================================================================
--- trunk/reactos/ntoskrnl/ex/sem.c (original)
+++ trunk/reactos/ntoskrnl/ex/sem.c Wed Jun 14 08:02:02 2006
@@ -129,7 +129,6 @@
0,
NULL,
&hSemaphore);
- ObDereferenceObject(Semaphore);
/* Check for success */
if(NT_SUCCESS(Status))
Modified: trunk/reactos/ntoskrnl/io/device.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/io/device.c?rev=22…
==============================================================================
--- trunk/reactos/ntoskrnl/io/device.c (original)
+++ trunk/reactos/ntoskrnl/io/device.c Wed Jun 14 08:02:02 2006
@@ -583,7 +583,6 @@
CreatedDeviceObject->DriverObject = DriverObject;
CreatedDeviceObject->NextDevice = DriverObject->DeviceObject;
DriverObject->DeviceObject = CreatedDeviceObject;
-
NtClose(TempHandle);
/* Return to caller */
Modified: trunk/reactos/ntoskrnl/io/iocomp.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/io/iocomp.c?rev=22…
==============================================================================
--- trunk/reactos/ntoskrnl/io/iocomp.c (original)
+++ trunk/reactos/ntoskrnl/io/iocomp.c Wed Jun 14 08:02:02 2006
@@ -273,7 +273,6 @@
0,
NULL,
&hIoCompletionHandle);
- ObDereferenceObject(Queue);
if (NT_SUCCESS(Status)) {
Modified: trunk/reactos/ntoskrnl/lpc/connect.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/lpc/connect.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/lpc/connect.c (original)
+++ trunk/reactos/ntoskrnl/lpc/connect.c Wed Jun 14 08:02:02 2006
@@ -878,7 +878,7 @@
ExFreePool(ConnectionRequest);
ExFreePool(CReply);
- ObDereferenceObject(OurPort);
+ //ObDereferenceObject(OurPort);
ObDereferenceObject(NamedPort);
return (STATUS_SUCCESS);
Modified: trunk/reactos/ntoskrnl/lpc/create.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/lpc/create.c?rev=2…
==============================================================================
--- trunk/reactos/ntoskrnl/lpc/create.c (original)
+++ trunk/reactos/ntoskrnl/lpc/create.c Wed Jun 14 08:02:02 2006
@@ -132,8 +132,6 @@
Port->MaxDataLength = LPC_MAX_MESSAGE_LENGTH;
Port->MaxPoolUsage = MaxPoolUsage;
- ObDereferenceObject (Port);
-
return (Status);
}
Modified: trunk/reactos/ntoskrnl/mm/section.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/mm/section.c?rev=2…
==============================================================================
--- trunk/reactos/ntoskrnl/mm/section.c (original)
+++ trunk/reactos/ntoskrnl/mm/section.c Wed Jun 14 08:02:02 2006
@@ -3408,7 +3408,6 @@
0,
NULL,
SectionHandle);
- ObDereferenceObject(SectionObject);
}
return Status;
Modified: trunk/reactos/ntoskrnl/ob/obdir.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/ob/obdir.c?rev=223…
==============================================================================
--- trunk/reactos/ntoskrnl/ob/obdir.c (original)
+++ trunk/reactos/ntoskrnl/ob/obdir.c Wed Jun 14 08:02:02 2006
@@ -553,9 +553,6 @@
}
_SEH_END;
}
-
- /* ReactOS HACK: ObInsertObject double-references */
- ObDereferenceObject(Directory);
}
/* Return status to caller */
Modified: trunk/reactos/ntoskrnl/ob/obhandle.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/ob/obhandle.c?rev=…
==============================================================================
--- trunk/reactos/ntoskrnl/ob/obhandle.c (original)
+++ trunk/reactos/ntoskrnl/ob/obhandle.c Wed Jun 14 08:02:02 2006
@@ -345,19 +345,7 @@
}
/* Increase the handle count */
- if(InterlockedIncrement(&ObjectHeader->HandleCount) == 1)
- {
- /*
- * FIXME: Is really needed? Perhaps we should instead take
- * advantage of the AddtionalReferences parameter to add the
- * bias when required. This might be the source of the mysterious
- * ReactOS bug where ObInsertObject *requires* an immediate dereference
- * even in a success case.
- * Will have to think more about this when doing the Increment/Create
- * split later.
- */
- ObReferenceObject(Object);
- }
+ InterlockedIncrement(&ObjectHeader->HandleCount);
/* FIXME: Use the Handle Database */
ProcessHandleCount = 0;
@@ -457,19 +445,7 @@
}
/* Increase the handle count */
- if(InterlockedIncrement(&ObjectHeader->HandleCount) == 1)
- {
- /*
- * FIXME: Is really needed? Perhaps we should instead take
- * advantage of the AddtionalReferences parameter to add the
- * bias when required. This might be the source of the mysterious
- * ReactOS bug where ObInsertObject *requires* an immediate dereference
- * even in a success case.
- * Will have to think more about this when doing the Increment/Create
- * split later.
- */
- ObReferenceObject(Object);
- }
+ InterlockedIncrement(&ObjectHeader->HandleCount);
/* FIXME: Use the Handle Database */
ProcessHandleCount = 0;
@@ -1531,11 +1507,9 @@
AccessMode,
NULL,
Handle);
+ if (!NT_SUCCESS(Status)) ObDereferenceObject(Object);
Cleanup:
- /* Dereference the object */
- if (Object) ObDereferenceObject(Object);
-
/* Delete the access state */
if (PassedAccessState == &AccessState)
{
@@ -1635,15 +1609,13 @@
AccessMode,
NULL,
Handle);
+ if (!NT_SUCCESS(Status)) ObDereferenceObject(Object);
/* Delete the access state */
if (PassedAccessState == &AccessState)
{
SeDeleteAccessState(PassedAccessState);
}
-
- /* ROS Hack: Dereference the object and return */
- ObDereferenceObject(Object);
/* Return */
OBTRACE(OB_HANDLE_DEBUG,
Modified: trunk/reactos/ntoskrnl/ob/obname.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/ob/obname.c?rev=22…
==============================================================================
--- trunk/reactos/ntoskrnl/ob/obname.c (original)
+++ trunk/reactos/ntoskrnl/ob/obname.c Wed Jun 14 08:02:02 2006
@@ -45,6 +45,7 @@
OBP_LOOKUP_CONTEXT Context;
POBJECT_HEADER_NAME_INFO ObjectNameInfo;
POBJECT_TYPE ObjectType;
+ PVOID Directory = NULL;
/* Get object structures */
ObjectHeader = OBJECT_TO_OBJECT_HEADER(Object);
@@ -68,7 +69,7 @@
0,
FALSE,
&Context);
- if (Object)
+ if ((Object) && !(ObjectHeader->HandleCount))
{
/* First delete it from the directory */
ObpDeleteEntryDirectory(&Context);
@@ -94,9 +95,15 @@
RtlInitEmptyUnicodeString(&ObjectNameInfo->Name, NULL, 0);
/* Clear the current directory and de-reference it */
- ObDereferenceObject(ObjectNameInfo->Directory);
+ Directory = ObjectNameInfo->Directory;
+ ObjectNameInfo->Directory = NULL;
+ }
+
+ /* Check if we were inserted in a directory */
+ if (Directory)
+ {
+ ObDereferenceObject(Directory);
ObDereferenceObject(Object);
- ObjectNameInfo->Directory = NULL;
}
}
}
Modified: trunk/reactos/ntoskrnl/ob/obref.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/ob/obref.c?rev=223…
==============================================================================
--- trunk/reactos/ntoskrnl/ob/obref.c (original)
+++ trunk/reactos/ntoskrnl/ob/obref.c Wed Jun 14 08:02:02 2006
@@ -113,6 +113,7 @@
Header->NextToFree);
/* Queue the work item */
+ KeBugCheck(0);
ExQueueWorkItem(&ObpReaperWorkItem, DelayedWorkQueue);
}
}
@@ -193,6 +194,7 @@
}
/* Find the object */
+ *ObjectPtr = NULL;
Status = ObFindObject(NULL,
&ObjectName,
Attributes,
@@ -204,18 +206,11 @@
NULL,
ParseContext,
NULL);
- if (!NT_SUCCESS(Status)) goto Quickie;
-
- /* ROS Hack */
- if (Object == NULL)
- {
- *ObjectPtr = NULL;
- Status = STATUS_OBJECT_NAME_NOT_FOUND;
- goto Quickie;
- }
-
- /* Return the object */
- *ObjectPtr = Object;
+ if (NT_SUCCESS(Status))
+ {
+ /* Return the object */
+ *ObjectPtr = Object;
+ }
/* Free the access state */
if (PassedAccessState == &AccessState)
Modified: trunk/reactos/ntoskrnl/ob/symlink.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/ob/symlink.c?rev=2…
==============================================================================
--- trunk/reactos/ntoskrnl/ob/symlink.c (original)
+++ trunk/reactos/ntoskrnl/ob/symlink.c Wed Jun 14 08:02:02 2006
@@ -359,9 +359,6 @@
}
_SEH_END;
}
-
- /* ReactOS Hack: Our ObInsertObject references an object twice */
- ObDereferenceObject(SymbolicLink);
}
/* Return status to caller */
Modified: trunk/reactos/ntoskrnl/ps/thread.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/ps/thread.c?rev=22…
==============================================================================
--- trunk/reactos/ntoskrnl/ps/thread.c (original)
+++ trunk/reactos/ntoskrnl/ps/thread.c Wed Jun 14 08:02:02 2006
@@ -313,7 +313,6 @@
DPRINT("About to dispatch the thread: %x!\n", &Thread->Tcb);
OldIrql = KeAcquireDispatcherDatabaseLock ();
KiUnblockThread(&Thread->Tcb, NULL, 0);
- ObDereferenceObject(Thread);
KeReleaseDispatcherDatabaseLock(OldIrql);
/* Return */
Modified: trunk/reactos/ntoskrnl/se/token.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/se/token.c?rev=223…
==============================================================================
--- trunk/reactos/ntoskrnl/se/token.c (original)
+++ trunk/reactos/ntoskrnl/se/token.c Wed Jun 14 08:02:02 2006
@@ -1507,8 +1507,6 @@
NULL,
&hToken);
- ObDereferenceObject(NewToken);
-
if (NT_SUCCESS(Status))
{
_SEH_TRY
@@ -2263,8 +2261,6 @@
DPRINT1("ObInsertObject() failed (Status %lx)\n", Status);
}
- ObDereferenceObject(AccessToken);
-
if (NT_SUCCESS(Status))
{
_SEH_TRY
@@ -2513,7 +2509,6 @@
Status = ObInsertObject(NewToken, NULL, DesiredAccess, 0, NULL,
&hToken);
- ObfDereferenceObject(NewToken);
}
else
{