Bug 322923 (MONO80229) - Segfault in gdb when trying to dereference a null System.Xml.XmlNode object
Summary: Segfault in gdb when trying to dereference a null System.Xml.XmlNode object
Status: RESOLVED INVALID
Alias: MONO80229
Product: Mono: Runtime
Classification: Mono
Component: misc (show other bugs)
Version: 1.2
Hardware: Other Other
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Atsushi Enomoto
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-12-12 00:15 UTC by Aaron Bockover
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
Test case exhibiting the segfault in gdb on null dereference of XmlNode (1.56 KB, text/plain)
2006-12-12 00:15 UTC, Thomas Wiest
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 20:19:23 UTC


---- Reported by abockover@novell.com 2006-12-11 17:15:06 MST ----

This is a strange bug, and is only present when running a mono application
from within gdb.

Take the following code snippet:

XmlNode node = parent.SelectSingleNode("i-do-not-exist");
Console.WriteLine(node.InnerText);

When not inside gdb, a NullReferenceException will be thrown when
dereferencing 'node.' However, if running under gdb, a segfault will be
thrown when dereferencing.

While the developer should always explicitly check for null before
dereferencing instead of relying on exceptions for flow control, a segfault
is quite bad. I found this after some code was introduced in Banshee that
did exactly that (rely on the exception), and I could no longer debug under
gdb as Banshee would always segfault on startup.



---- Additional Comments From abockover@novell.com 2006-12-11 17:15:40 MST ----

Created an attachment (id=171083)
Test case exhibiting the segfault in gdb on null dereference of XmlNode




---- Additional Comments From miguel@ximian.com 2006-12-11 17:52:40 MST ----

segfaults are converted by the runtime to NullReferenceExceptions.

If you do not want to see that in GDB, you need to use the standard:
handle SIGSEGV pass noprint 

command.

This is not a Mono bug.

Imported an attachment (id=171083)

Unknown operating system unknown. Setting to default OS "Other".