Is this a bug?

Here you can discuss ReactOS related topics.

Moderator: Moderator Team

Post Reply
acoma
Posts: 4
Joined: Fri May 22, 2009 2:40 pm

Is this a bug?

Post by acoma » Fri May 22, 2009 2:53 pm

I confused with this code:

LONG
FASTCALL
ObDereferenceObjectEx(IN PVOID Object,
IN LONG Count)
{
POBJECT_HEADER Header;
LONG NewCount;

/* Extract the object header */
Header = OBJECT_TO_OBJECT_HEADER(Object);

/* Check whether the object can now be deleted. */
NewCount = InterlockedExchangeAdd(&Header->PointerCount, -Count);
if (!Count) ObpDeferObjectDeletion(Header);

/* Return the current count */
return NewCount;
}

Is this should be NewCount?

hto
Developer
Posts: 2193
Joined: Sun Oct 01, 2006 3:43 pm

Post by hto » Fri May 22, 2009 4:42 pm

Thank you very much!

There are even two bugs. First, InterlockedExchangeAdd returns old count. And then if checks wrong variable.

Ghostshaw
Posts: 1
Joined: Mon Oct 02, 2006 6:15 pm

Re: Is this a bug?

Post by Ghostshaw » Fri May 22, 2009 4:51 pm

Actually you could say theres 3 bugs, since count could be greater then PointerCount resulting in negative PointerCount which would still need to get it deleted, but with the current code (even if you replace Count with header->pointercount) wouldn't do so.

bugboy
Developer
Posts: 39
Joined: Thu May 22, 2008 9:23 pm

Re: Is this a bug?

Post by bugboy » Fri May 22, 2009 4:51 pm

If you would like to give a name, credit should be given in commit.

mjmartin

hto
Developer
Posts: 2193
Joined: Sun Oct 01, 2006 3:43 pm

Post by hto » Fri May 22, 2009 5:08 pm

I would rather add there a check for a negative count and a debug print.

acoma
Posts: 4
Joined: Fri May 22, 2009 2:40 pm

Re: Is this a bug?

Post by acoma » Fri May 22, 2009 5:30 pm

Can we change to :

if ((NewCount - Count)<=0) ObpDeferObjectDeletion(Header);

Lone_Rifle
Test Team
Posts: 802
Joined: Thu Apr 03, 2008 2:17 pm
Contact:

Re: Is this a bug?

Post by Lone_Rifle » Fri May 22, 2009 5:32 pm

If you ever spot more bugs in future, join us at Freenode IRC, #reactos. The dev team hangs out there and can entertain your queries quicker.

acoma
Posts: 4
Joined: Fri May 22, 2009 2:40 pm

Re: Is this a bug?

Post by acoma » Fri May 22, 2009 5:37 pm

Thank you, I will

hto
Developer
Posts: 2193
Joined: Sun Oct 01, 2006 3:43 pm

Post by hto » Fri May 22, 2009 6:23 pm

acoma wrote:Can we change to :

if ((NewCount - Count)<=0) ObpDeferObjectDeletion(Header);
No. Or ObpDeferObjectDeletion can be called more then once.

fireball
Developer
Posts: 358
Joined: Tue Nov 30, 2004 10:40 pm
Location: Moscow, Russia
Contact:

Re: Is this a bug?

Post by fireball » Fri May 22, 2009 7:20 pm

Thanks, I fixed this and other related bugs in r41043.

The123king
Posts: 242
Joined: Mon Jun 16, 2008 6:51 pm

Re: Is this a bug?

Post by The123king » Fri May 22, 2009 7:46 pm

Nice to see this bug fixed :)

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 6 guests