Bugzilla – Bug 322923
Segfault in gdb when trying to dereference a null System.Xml.XmlNode object
Last modified: 2007-09-15 21:24:46 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".