SPCodeOrg / SPCode

A lightweight SourcePawn editor.
https://forums.alliedmods.net/showthread.php?p=2693577
61 stars 14 forks source link

Crashing after `=` sign #41

Closed PeakKS closed 4 years ago

PeakKS commented 4 years ago

Its frequently crashing when I try to type "something = " without having a ; at the end of the line already

PeakKS commented 4 years ago

example crash log:

1
Section: SPCODE MAIN
.NET Version: 4.0.30319.42000
OS: Microsoft Windows NT 6.2.9200.0
64 bit OS: TRUE
64 bit mode: TRUE
Dir: C:\Users\bbats\AppData\Roaming\spcode
Working Set: 167952 kb
Installed UI Culture: en-US
Current UI Culture: en-US
Current Culture: en-US

Exception 1
Message:
Index was outside the bounds of the array.
Stacktrace:
   at SourcepawnCondenser.LocalVars.ConsumeSMVariableLocal(Token[] t, String FileName)
   at SourcepawnCondenser.Condenser.ConsumeSMFunction()
   at SourcepawnCondenser.Condenser.Condense()
   at SPCode.UI.Components.EditorElement.Caret_PositionChanged(Object sender, EventArgs e)
   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at ICSharpCode.AvalonEdit.Editing.Caret.OnDocumentUpdateFinished()
   at ICSharpCode.AvalonEdit.Editing.TextArea.ReceiveWeakEvent(Type managerType, Object sender, EventArgs e)
   at System.Windows.WeakEventManager.ListenerList.DeliverEvent(Listener& listener, Object sender, EventArgs args, Type managerType)
   at System.Windows.WeakEventManager.ListenerList.DeliverEvent(Object sender, EventArgs args, Type managerType)
   at System.Windows.WeakEventManager.DeliverEvent(Object sender, EventArgs args)
   at ICSharpCode.AvalonEdit.Document.TextDocument.Replace(Int32 offset, Int32 length, ITextSource text, OffsetChangeMap offsetChangeMap)
   at ICSharpCode.AvalonEdit.Editing.EmptySelection.ReplaceSelectionWithText(String newText)
   at ICSharpCode.AvalonEdit.Editing.TextArea.PerformTextInput(TextCompositionEventArgs e)
   at ICSharpCode.AvalonEdit.Editing.TextArea.OnTextInput(TextCompositionEventArgs e)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.TextCompositionManager.PostProcessInput(Object sender, ProcessInputEventArgs e)
   at System.Windows.Input.InputManager.RaiseProcessInputEventHandlers(ProcessInputEventHandler postProcessInput, ProcessInputEventArgs processInputEventArgs)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.TextCompositionManager.PostProcessInput(Object sender, ProcessInputEventArgs e)
   at System.Windows.Input.InputManager.RaiseProcessInputEventHandlers(ProcessInputEventHandler postProcessInput, ProcessInputEventArgs processInputEventArgs)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndKeyboardInputProvider.ProcessTextInputAction(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.OnPreprocessMessage(Object param)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
   at System.Windows.Interop.HwndSource.OnPreprocessMessageThunk(MSG& msg, Boolean& handled)
   at System.Windows.Interop.ThreadMessageEventHandler.Invoke(MSG& msg, Boolean& handled)
   at System.Windows.Interop.ComponentDispatcherThread.RaiseThreadMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at SPCode.Program.Main(String[] args)
Source:
SourcepawnCondenser
HResult Code:
-2146233080
Helplink:
null
Targetsite Name:
ConsumeSMVariableLocal
maxijabase commented 4 years ago

I read about this issue when it first came out in #29 and I was about to comment there, but I thought it was more pertinent to do it here since it's about the same issue and the other one got closed. I managed to recreate this crash in an old .sp file but I have no idea how to do it consistently, I just have in my possession a file that triggers the crash. I will attach it, as well as the crash dump. Keep in mind SPCode crashes as soon as you open the file. CRASH_581140.txt ratawar.zip

maxijabase commented 4 years ago

Update: apparently I can recreate it by pasting the code chunk from #29 in any project. Here's a demonstration:

C4O6JjNHzi

Hexer10 commented 4 years ago

Which version are you using? Could you try to reproduce the crash downloading the latest version? I'm not able to reproduce this

FAQU2 commented 4 years ago

Same issue here, and I'm able to recreate it. To reproduce try this :

#include <sourcemod>
#include <sdktools>

#pragma semicolon 1
#pragma newdecls required

public Plugin myinfo = 
{
    name = "Name of plugin here!",
    author = "Your name here!",
    description = "Brief description of plugin functionality here!",
    version = ""
};

public void OnPluginStart()
{
    HookEvent("player_spawn", OnPlayerSpawn)
}

public Action OnPlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
    int client
}

As soon as I add = after int client, SPCode crashes. I'm using the latest version. (1.6.1.1)

PeakKS commented 4 years ago

Yeah pasting @FAQU2 's example in instantly crashes me as well after I add the =. I'm using 1.6.1.1 I'll also note that this didn't happen until I got the 1.6.1.0 and 1.6.1.1 update via the built in updater as opposed to downloading a new release from github.

Natanel-Shitrit commented 4 years ago

I'm PRing an experimental fix for this, it will be really helpful if someone could confirm it solved the issue :)

PeakKS commented 4 years ago

I built without the change and @FAQU2 's example crashed, I built with that change and It didn't, so seems like the fix works.

Natanel-Shitrit commented 4 years ago

I hope it solved it once and for all, if it crashes for someone - please reopen this issue, thanks for helping 😃 Closed.