Skip to content

System.NullReferenceException in PythonTextEditor.Write causing Revit to crash #158

Open
@alexworkorb

Description

@alexworkorb

Describe the bug
Sometimes Revit crashes due to a Null pointer exception traced to PythonTextEditor.Write

To Reproduce
Steps to reproduce the behavior:

Expected behavior

Screenshots
image

Windows event log:

Faulting application name: Revit.exe, version: 24.1.11.26, time stamp: 0x64ff47ef
Faulting module name: ntdll.dll, version: 10.0.22621.3733, time stamp: 0x67ca8829
Exception code: 0xc0000374
Fault offset: 0x000000000010c8f9
Faulting process id: 0x0x45E4
Faulting application start time: 0x0x1DAE118D918C487
Faulting application path: C:\Program Files\Autodesk\Revit 2024\Revit.exe
Faulting module path: C:\Windows\SYSTEM32\ntdll.dll
Report Id: 79327c40-7a4a-4c0b-bdcb-5102af93c7fa
Faulting package full name: 
Faulting package-relative application ID: 

-----------------------------------
Application: Revit.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException
   at System.Text.StringBuilder.Append(System.String)
   at PythonConsoleControl.PythonTextEditor.Write(System.String, Boolean, Boolean)
   at PythonConsoleControl.PythonConsole.ExecuteStatements()
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
   at PythonConsoleControl.PythonConsole.DispatcherThreadStartingPoint()
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.ThreadHelper.ThreadStart()


Desktop (please complete the following information):

  • OS: Windows 11 Pro 10.0.22631 Build 22631
  • Revit 2024
  • Revit Python Shell 2.0.2

Additional context
We keep encountering this issue when exporting ViewSections into DWG's (using doc.Export)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions