Notepad++ crashes and erases the file being worked on.



  • @W-C
    if you want to go the python script way,
    here is described how it could look like. If you want modification, checks etc… let us know.

    Cheers
    Claudia



  • I was using the last file that was created and using “save as” to a new file name. Then erasing the old data and entering the new data in the new file.

    As I said previously, I am wondering if the “underlying” formatting for the original file (what we don’t see but is necessary to create a file behind the scenes) was corrupted.

    Time will tell since I recently copy-pasted the data in the original file to a “new” file, thus getting rid of the old one completely. There is no connection between the two. This “may” resolve the issue.



  • Which Notepad++ version are you using. The phrase “I am using the very last version provided” is not precise.



  • This post is deleted!


  • I just encounter the exact same problem today, notepad++ crashes and erases my file. As a general notice i have to say that notepad++ from a stable must use tool for the last 1-2 year it’s an unstable tool that crashes quite often, but so far i didn’t loose any work until today.
    I’m using notepad++ in 3 different machines one with windows 10, one windows 7 and one which is an iMac with windows 7).
    The problem today appeared on my imac windows 7 installation (works perfectly for 3 years), anyway here is my debug info from notepad++
    Notepad++ v7.5.7 (32-bit)
    Build time : Jun 29 2018 - 00:46:55
    Path : C:\Program Files (x86)\Notepad++\notepad++.exe
    Admin mode : OFF
    Local Conf mode : OFF
    OS : Windows 7 (64-bit)
    Plugins : AutoSave.dll ComparePlugin.dll CSSExplorerAdapter.UNICODE.dll HTMLTag_unicode.dll JSMinNPP.dll NPPJSONViewer.dll NppSaveAsAdmin.dll PluginManager.dll XMLTools.dll DSpellCheck.dll mimeTools.dll NppConverter.dll NppExport.dll



  • sorry for reposting after searching in google i find a solution, my missing data from the file was there %AppData%\Roaming\Notepad++\backup. solution link https://stackoverflow.com/questions/21712139/notepad-how-to-recover-a-deleted-file



  • @Dimitris-Stefanakis
    Thanks man, this helped me a lot!
    Just pressed ctrl+s and boom! Crash and file is empty

    Notepad++ v7.5.8 (32-bit)
    Build time : Jul 23 2018 - 02:03:53
    Path : C:\Program Files (x86)\Notepad++\notepad++.exe
    Admin mode : OFF
    Local Conf mode : OFF
    OS : Windows 8.1 (64-bit)
    Plugins : ComparePlugin.dll DSpellCheck.dll mimeTools.dll NppConverter.dll NppExport.dll



  • MINE AS WELL. I too have had the problem of notepad++ crashing and erasing my programs. I back my stuff up very regularly, but not always daily. At one point I know I had entirely too many open programs which did understandably crash it a couple times with no loss of data ( programs erased). I since refrained from excessive open programs. but after that, and with reinstalled newest version it started eating my programs. Html & javascript webGL locally ran applications I was developing. Twice it occurred while attempting to make 3D iframe alpha-transparent. First time I was able to save the open firefox instance of it and straighten out the DOM rearranged stuff. Second time it occurred I lost a weeks worth of work and was unable to save in that manner. Third time I wasn’t working on the 3D html, but a newest Three.js library test scene. I have started creating a little stack of three exact same versions of anything important I put in there now. It has been (notepad++) deleted and reinstalled ea time except this last time. The Toshiba windows 10 does not go online for any reason ever. I also would like this matter considered seriously. I LIKE my notepad++, I LIKE the dark background and light code script, styles. Why would I want to use windows notepad. I don’t have a clue what to use for alternative code editor, any proprietary-ware is out of the question. I wouldn’t even know where to start at troubleshooting why this would occur, I have looked for months for a post of this nature to begin addressing this very serious problem and only now just found it ( this post). I hope my reporting it here is in some way helpful, any additional information someone might need I have overlooked I will be happy to add. Thanks, freemnemoryerror (mike)



  • @Mike-Depping ,

    What is your Notepad++ version and could you briefly describe what exactly happened?



  • Sorry for delayed response. This site would not let me edit or
    repost. I also appologize for not more thouroughly reading entire post before posting.

    current version: Notepad++v7.2 (64-bit)
    listed under plugins: Converter, MIME Tools
    Path 1st and 2nd instance of: C:\Program Files (x86)\Notepad++\notepad++.exe
    Path 3rd instance of: somewhere else, on hard drive.
    Admin mode : not sure and I can’t find where that would be listed
    Local Conf mode : not sure and I can’t find where that would be listed
    OS : Windows 10 (64-bit)

    No changes, no reicently installed programs, Notepad++'s machine never goes online.

    saves were ‘Save’ not ‘Save as’

    No use of online cloud anything ever.
    First 2 deletions large file 3821 lines (145 KB)
    Third deletion was small file.
    The spellcorrect/suggestions thing was acting oddly between 2nd and third deletion incidents,
    changing things on occasion.

    wifi was active in vacinity during all deletion incidents but not connected on machine. ( I’m Mike above)



  • @Mike-Depping , @logic-error ,

    Does the problem occur often?
    Is your Notepad++ periodic backup feature turned ON?

    Notepad++ version 7.6 has fix for this issue (or similar) so I’m trying to figure out if the fix covers your case as well.
    Please update Notepad++ if you can and try with it.
    I have to warn you though that the plugins installation and location paths have changed in 7.6 and that may lead to problems finding your plugins. You might need to manually fix that but there is nothing to worry about. You can find info about the new 7.6 plugin handling and paths in the community posts or here as well: https://notepad-plus-plus.org/news/notepad-7.6-released.html .



  • Three times, or three deletions of my file being edited.
    Under Settings > Preferences > Backup, I have:
    Backup every 7 seconds, then it’s path does correspond with my current path.
    Then under ‘Backup on save’ , NONE is selected with no custom backup directory added



  • @logic-error

    If you are going to stick with your version 7.2, I would suggest you turn all “backup” options off…and see what happens going forward…good luck.



  • I’m sorry again for slow responses, I get site error ‘HERE’
    if I do anything other than enter a preprepared response.
    This site won’t let me edit or immediate reply. prefer not to get wrapped up in all that as I already
    have a nice little problem to work on.

    If not the v7.2 is there a version attainable you might recommend?

    Thank you, So if I have this correct, I will go to my version 7.2 under:
    Settings > Preferences > Backup
    and uncheck the ‘Remember current session for next launch’? and
    uncheck the 'Enable session snapshot and periodic backup,
    remove the timer variables if they need removed after these are unchecked (I’m assuming they wont)
    remove path, and leave None as None.

    Erasing ones programs is beyond MESSED UP, I would expect that kind of thing as a ploy for an
    application to get one to turn pro/ proprietary ware, or a competitors taking advantage
    of a weakness or vulnerability. thank you all again for your time. I see no real
    altermative but to try to find another useable code editor, preferably one
    that doesn’t just up and erase my stuff.



  • @logic-error ,

    I’m sorry, I couldn’t understand well your last post.
    You know, every program has it’s flaws (some might be really critical), they stay dormant and unnoticed but when they appear and are known they get fixed and the cycle repeats.

    If you decide to continue using Notepad++ get version 7.6 or bigger and you shouldn’t have problems like the one you described.



  • I am amazed that so many people are having this problem, for so many years, and still there is no solution to it.
    What’s the use of coding in so many features and functionality when basic stability is not looked at.
    Today is 12-Mar-2020 and Win10 I believe updated overnight, and when I relaunch Notepad++ the whole session (a mix of saved and unsaved files) has disappeared, and I stare at a Blank file.
    Obviously, no error messages, and hence no dump files, etc.

    I have ticked “Remember Current Session for next Launch”
    And also “Enable Session Snapshot and Periodic Backup”. with a Backup every 7 seconds.

    But what is the Use of having a Session Backup System which will ditch you when you need it the most.

    If there is a Periodic Session Backup system, then where are the Previous Backups. Can Notepad++ not recognize when it is over-writing a File with Data, with a Blank file.

    We of course appreciate the Functionality of Notepad++ and fall heavily on it. We build our castles on it, and then type out data trusting it to keep it intact. And just when we least expect it, it pulls the rug from under the feet, and presents us a Neat Blank Page…



  • Don’t know for sure but I recommend for you to disable “Session Snapshot and Periodic Backup”.
    I believe it is part of the problem rather than the solution.

    Notepad++ like other legacy GUI applications is almost entirely single threaded running the Windows message loop.
    Last time I looked (admittedly long ago) it seemed that the snapshot feature adds multithreading into Notepad++ which is not properly synchronized/locked with the rest of the single threaded code. I believe that if “shit happens” when this backup thread is active, either files may be wiped or empty files are written into the backup and these empty files are restored on the next restart overwriting the OK files. I never enabled this feature and never lost a file.

    Feel free to use “Remember Current Session” since this feature just tell the main thread to save file locations before Notepad++ exits.

    Some people are so lazy/unresponsible that they never save files and expect the snapshot to remember their modified files. But they really deserve to lose a few hours (or days) of work from time to time.



  • @gstavi ,

    You are totally right about Notepad++ being mainly single-threaded and that the periodic backup uses multi-threading but that is not the problem.
    I made PR maybe a year ago that fixed possible race conditions between the threads and it was merged. I also tested it at the time, @Claudia-Frank tested it too and periodic backups proved to be working properly.

    The problem remains to be the disk write caching that delays the actual write to the disk which leads to loss of data on sudden power loss or reboot (due to update for example).
    I actually did this PR to fix the problem and in relation to these reported issues (https://github.com/notepad-plus-plus/notepad-plus-plus/issues/6133 and https://github.com/notepad-plus-plus/notepad-plus-plus/issues/5664) but it was rejected.

    Don has written in the release notes of the latest Notepad++ version this:

    Fix Notepad++ doesn’t exit correctly while Windows 10 update restart.

    I don’t know if that helps though and in what cases.
    Here is the link: https://notepad-plus-plus.org/downloads/v7.8.5/


    @Shrikant-Shrinivas ,

    I’m sorry for your data loss, Notepad++ can really do better in that situation but I would advise you to always save your work and close Notepad++ when leaving the computer for longer periods (especially don’t leave it open overnight) to minimize the chances of this happening.
    You could try using Recuva to try recovering your lost files.

    BR



  • @pnedev
    Since I looked at the code much longer ago than 1 year then perhaps you fixed the things I saw back than.
    I hope you indeed fixed ALL the races because this is one of the more difficult challenges for SW developers.

    I am not convinced about disk caching explanation because this should have made it a common problem for lots of application.

    If it helps in any way I also made a patch that changes Notepad++ file api. My reason was that fopen was resetting file permissions and ownership over SAMBA. Specifically losing the ‘execution’ permission of script files. Perhaps a combination of reasons will convince @donho at some point.
    Do remember it if you ever choose to fix the out-of-space bug by creating a new file since it will introduce the same problem. A new file will have default permissions rather then the possibly specific permissions of the original file.



  • @gstavi ,

    Good points.

    I hope you indeed fixed ALL the races

    I did. Those related to periodic backups.

    I am not convinced about disk caching explanation because this should have made it a common problem for lots of application.

    It is apparently a common problem for other applications too.
    Here is another debate on the topic:
    https://community.notepad-plus-plus.org/post/48725

    Your patch looks good but to avoid the disk caching problems you need to use FILE_FLAG_WRITE_THROUGH (or in your used Win API it should be _WRITE_THROUGH, I’m not sure) when creating/opening the files.

    As I’ve written before in several places the problems are two:

    1. fopen erases file contents on open with write permissions. This is causing the “no-space on disk” file contents loss problem and perhaps the problem you have encountered and are mentioning here.
    2. File contents loss on reboot/power loss (even when files are edited and saved) are caused by disk write caching (defined by Microsoft as “lazy writer” in some of their documents).

    Perhaps a combination of reasons will convince @donho at some point.

    I doubt it. A lot of people (including me) had given him a lot of reasons already including the root cause of the problems and a possible fix.

    Do remember it if you ever choose to fix the out-of-space bug by creating a new file

    I though about it in the beginning when I was trying to figure out the cause of the write issues.

    In my PR I actually use native Win32 file handling API as you do in your patch to avoid the fopen file contents erasure. There is no need to create new file in that case - forget that I mentioned it (it was just a possible and sub-optimal workaround to the first problem I gave above).


Log in to reply