2

I've faced some rather strange problem when writing a C# code. I have the following classes:

  • A Node class:

    class Node
    {
        public char value;
        public Node left;
        public Node right;
    
        public Node(char _value)
        {
            value = _value;
            left = null;
            right = null;
        }
    }
    
  • A Tree class:

    class Tree
    {
        private Node root;
    
        public Tree(Node _root)
        {
            root = _root;
        }
    
        public void Inorder(Node root)
        {
            Inorder(root.left);
            Console.WriteLine(root.value);
            Inorder(root.right);
        }
    }
    
  • In Main, I wrote something like:

       Node n1 = new Node('a');
       Tree tree = new Tree(n1);
       tree.Inorder(n1);
    

An unhandled exception briefly appears in the console, then my computer crashes and the "blue screen of death" appears with the following piece of information:

  • Stop code: KMODE_EXCEPTION_NOT_HANDLED
  • What failed: clipsp.sys

When I try to open my Main file after the computer is restarted, it contains this:

    <?xml version="1.0" encoding="utf-8"?>
    <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Mi

Now I know my code is not right (there is a null unhandled exception, because it tries to find the left child of a "null" node), but I'm pretty sure my computer shouldn't behave like this.

I've disabled my Fast Startup feature as I found this on the internet, but it still crashes. If somebody has any idea where the problem is, I would be grateful.

  • This is just wrong. Your computer might be the problem. You should try this in another. However, you should also check the root.left and root.right being null before calling Inorder again. – Vinícius Gabriel Feb 25 '19 at 23:59
  • A naive guess, possibly passing the object to Console causes the exception to be thrown and then not handled in the console API, rather than your program. What happens if you take out that line? – Koenigsberg Feb 26 '19 at 00:02
  • Also - disable Windows Defender. You running Avast? – Koenigsberg Feb 26 '19 at 00:05
  • This is a bug in your VS (possibly install-related), and/or a bug in one of your drivers or a hardware problem with your computer. And @Mär makes a good point. AV software is usually driver-level. So that's a potential problem as well – zzxyz Feb 26 '19 at 00:05
  • To clarify, you should 100% be able to run this code without your computer BSODing. Yes, it's wrong. That's unimportant. Your computer should not crash. – zzxyz Feb 26 '19 at 00:10
  • 1
    By the way, the problem was Avast. It worked perfect as soon as I uninstalled it. – Gabriel Pop Feb 28 '19 at 00:13

0 Answers0