Closed Bug 394405 Opened 17 years ago Closed 17 years ago

Use-after-free guard in nsMacWindow::~nsMacWindow makes Jesse sad

Categories

(Core Graveyard :: Widget: Mac, defect)

1.8 Branch
x86
macOS
defect
Not set
trivial

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: jruderman, Assigned: jaas)

References

Details

(Keywords: regression)

>  // Explicitly reset mMacEventHandler to null so that any use after free of
>  // this object crashes on a null-ptr deref rather than using freed memory.
>  // ~auto_ptr() only deletes the pointer, it does not set it to null.

Should be changed to make it clear that the line below simply makes it *more likely* that the crash will dereference null, rather than guaranteeing it.  The nsMacWindow's own memory is freed, after all.

>  mMacEventHandler.reset(nsnull);

In debug builds, it might be better to set this to 0xdddddddd, so a developer who sees the crash won't think it's a safe null-dereference crash.  (Or do debug builds automatically set all of the freed nsMacWindow's memory to 0xdddddddd anyway?)
> simply makes it *more likely*

Sure, that's what I meant.
This file is removed on trunk so I'm not sure either of these
nits are worth fixing.

> (Or do debug builds automatically set all of the freed nsMacWindow's memory
> to 0xdddddddd anyway?)

AFAIK, not for objects that are allocated with default malloc/new.
We only do that for arena-allocated objects.

Generic memory problems are better detected using external tools,
like valgrind, MallocDebug etc.  The MallocDebug stuff on MacOSX
are quite good IIRC.
http://developer.apple.com/documentation/Performance/Conceptual/ManagingMemory/Articles/MallocDebug.html
http://developer.apple.com/documentation/Performance/Conceptual/ManagingMemory/Articles/FindingLeaks.html
Version: Trunk → 1.8 Branch
Oh, this is branch-only?  Feel free to ignore me, then :)
Yes, 1.8.1 branch only.

-> WONTFIX
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → WONTFIX
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.