Debugging "Plugin Crash"



  • How do I figure out the cause of the following error message types:


    Plugin Crash

    XPatherizerNPP.dll just crashed in
    notify(SCNotification *notification) :
    notification->nmhdr.code == 1005
    notification->nmhdr.hwndFrom == 0000000000080938
    notification->nmhdr.idFrom == -611365728

    I am trying to resurrect XPatherizerNPP: https://code.google.com/archive/p/xpatherizernpp/

    I’ve successfully compiled the plugin and gotten Npp 7.5.4 to run it - I had to replace the NPPPluginNetHelper.cs code with the newer version from NppToolBucket.

    When I open NotePad++ I receive a number of crash warnings like the example above. The plugin actually works great, it seems as though the errors are inconsequential…

    I’ve set Notepad++ as the external program in VS 2017 Community and put in break points, but I’ve spent about 3 hours looking for the error and can’t isolate it.

    I have literally no idea what I’m doing. I don’t code in C# and the first time I took a swing at N++ plugins was last Friday. Any pointers would be appreciated as I intend to get this plugin working again hell or high water.



  • Do you have a github repo with your current work?



  • Code is back at the office and I’m having a heck of a time getting it rebuilt from the original source… Not sure what I’m doing wrong. Will get it on GIT ASAP.





  • I’ve forked the XPatherizerNPP github project and it can be downloaded here:

    https://github.com/shrout1/xpatherizernpp

    Thank you for suggestion on the other plugin! XML Tools seems a bit unstable, also its XPath component doesn’t seem to work correctly. Attempting to evaluate “.” in a Microsoft sample XML file does not return any nodes… The plugin loads, but the XPath functionality doesn’t seem to work. All dependencies have been installed per the installation readme.

    Please let me know if there are any issues with my project upload; I have limited experience with git. I’ve spent a long time working IT but only dabbled with development.

    Thanks very much!



  • Stating what is probably obvious, it appears the the plugin infrastructure can’t handle the messaging protocols of the current version of Notepad++. I am trying to borrow newer implementations of the infrastructure from other plugins, though it will be patch work at best as I don’t understand most of the code I am looking at.



  • See https://github.com/kbilsted/NotepadPlusPlusPluginPack.Net for the current version also the files are splitted up more, but has nicer interfaces to access data.
    Have you checked if the 32bit build suffers from the same issues?



  • @chcg - I saw your update to the DLLexport folder; didn’t catch it before I made a new update:

    https://github.com/shrout1/xpatherizernpp/tree/Updated_Infrastructure/XPatherizerNPP

    I’m seeing a new error now: “XPatherizerNPP.dll just crashed in runPluginCommand(size_t i : 22)”

    Not a lot of reference material for that online.

    Otherwise I solved the SCNotification issues by remapping the main.cs calls to “ScNotification” in the Scintilla_iface.cs file, changed the “nc.nmhdr.code” calls to “nc.Header.Code” and redefined all the namespaces from “XPatherizerNPP” to “Kbg.NppPluginNET” and “Kbg.NppPluginNET.PluginInfrastructure”

    I borrowed from the https://github.com/kbilsted/NppPluginGuidHelper plugin and used all infrastructure there.

    Any suggestions are still appreciated!



  • Like to note that I only see the error “XPatherizerNPP.dll just crashed in runPluginCommand(size_t i : 22)” when I try to “Show XPatherizer Windows”



  • So it’s choking on the ScNotification messages when Notepad++ runs “UnmanagedExports.cs”. The form object is “null” and I’m not sure how it creates an instance of the form… It gets through line 66 of “UnmanagedExports.cs” when trying to load the form and crashes.



  • I’ve not given up…

    I discovered that the “Notification” routine in Main.CS is no longer triggered by UnmanagedExports.cs. I changed the function name to “OnNotification” and modified the argument to match the object being passed in from “beNotified” in the UnmanagedExports.cs callback.

    This caused the event handler to correctly trigger when NPP finishes loading, initializing the search & result forms prior to them being called. The “XPatherizerNPP.dll just crashed in runPluginCommand(size_t i : 22)” error is now gone as it is not trying to load a null form object.

    Now the problem is that the Scintilla interface does not appear to be returning the correct memory address for the file that is meant to be analyzed. From line 42 in NppPluginNETBase.cs:

    Win32.SendMessage(nppData._nppHandle, (uint) NppMsg.NPPM_GETCURRENTSCINTILLA, 0, out curScintilla);

    This returns an address that, when passed into “SciMsg.SCI_GETTEXT” returns a whole big bunch of gibberish (looks like Asian characters of some kind). Soooo I’m trying to figure out what’s going on with that. Slow progress! Learning as I go…

    I’ve updated the code in the git repo: lhttps://github.com/shrout1/xpatherizernpp/tree/Updated_Infrastructure/XPatherizerNPP



  • Did you build the plugin for 32bit and checked that it is working there as expected?

    Additionally maybe remove the int casts in NppPluginNETHelper.cs from

        public ClikeStringArray(int num, int stringCapacity)
        {
            _nativeArray = Marshal.AllocHGlobal((num + 1) * IntPtr.Size);
            _nativeItems = new List<IntPtr>();
            for (int i = 0; i < num; i++)
            {
                IntPtr item = Marshal.AllocHGlobal(stringCapacity);
                Marshal.WriteIntPtr((IntPtr)(_nativeArray + (i * IntPtr.Size)), item);
                _nativeItems.Add(item);
            }
            Marshal.WriteIntPtr((IntPtr)(_nativeArray + (num * IntPtr.Size)), IntPtr.Zero);
        }


  • @chcg Thanks! I have changed the plugin to 32 bit.

    I’ve actually got the SCI_GETTEXT working by utilizing the “ScintillaGateway” object as defined in the plugin infrastructure I’ve integrated.

    It appears that the old “SciMsg.SCI_GETTEXT” was returning ASCII when I needed Unicode. The plugin infrastructure somehow resolves this, and I’m simply leaning on that to get it done.

    Now my issue appears to be that the XML Nodes are being parsed incorrectly… The parent node is being listed as a child of itself in the output… I’m slowly digging through the source code to figure out what element is chopping up the XML.

    Thanks for the help and suggestions! I’ve uploaded the new code to GIT again.



  • Ok, I’ve merged the branch back into master and it seems like everything works… I don’t know what the XPML functionality is supposed to be, and without a working version I’m not sure how to troubleshoot it. I’ve removed the XPML options from the menu.

    The functional 32 bit version of the plugin is available here:

    https://github.com/shrout1/xpatherizernpp


Log in to reply