Fix corrupted txt file (NULL)
Now you are more specific.
What is your Notepad++ version?
Where the corrupted files modified (were still unsaved when the power loss occurred) or those were not modified?
I don’t think you can recover the files in any way, sorry, that’s really a nasty situation.
wisemike2 last edited by
Notepad v7.2.2 (32 bit)
and ya, the files were being modified at the moment of the crash.
OK, can you try to reproduce this on purpose?
Restart your computer, open a single test file in N++, modify it a bit but do not save it.
Then simulate power outage - unplug the computer or switch it off through the button.
Is the file corrupted when you next restart?
I’ll test it myself on my machine and write back.
I just tried that scenario on Linux under Wine, Notepad++ v7.3.2.
The file has zero size - totally empty. So yes, power loss leads to unsaved files corruption.
That needs to be investigated.
Alan Kilborn last edited by
I believe that a lot of the “total data loss” postings on this Community can be avoided if people simply turn on the Verbose Backup feature. With this feature turned on, Notepad++ creates a backup copy of the file every time the user saves. This has helped me out on quite a few occasions.
Settings menu -> Preferences ->Backup -> (then Checkmark) Verbose backup
Claudia Frank last edited by
Unfortunate this functionality is also the cause of some problems.
What’s really weird is that, normally, npp opens the file for reading,
once done it closes it and you only work with the buffer in the editor.
No file interaction until you save the file.
I don’t understand how it could happen that a power loss can corrupt the file
if the file hasn’t been opened at that time. And as Pavel was easily able to reproduce
there must be something strange going on. Or, the backup has been enabled and this
was causing it but reproducing it easily doesn’t indicate it.
Hi @Claudia-Frank ,
I agree with you - something is not right, that shouldn’t be happening. The changes should be in memory only and not related to the file content currently on the disk. I did the test with disabled backup. It is possible to be a Scintilla issue.
If I have time this weekend I’ll do some more tests on a native Windows.
wisemike2 last edited by
At the time of the loss of the file, I didn’t have the backup options on, so it’s not related.
One update - I tried the scenario on native Windows 7 and the issue did not appear.
It’s getting even more weird…
After my latest test under Wine the issue again did not appear.
It seems it is not steadily reproducible which makes it really hard to debug.
Claudia Frank last edited by
thx for your effort.
In the meantime I tried to reproduce by killing the app too and it happened
once out of 10 tries. (after 10 tries I stopped)
Backup disabled all the time.
I searched the source (npp and scintilla part) for FILE occurrences and tried
to understand what happens but none of them give an indication what could have caused it.
Btw. do you cross compile? If so, some hints what I should take care of if I want to rebuild
npp and scintilla on linux?
pnedev last edited by pnedev
Hi @Claudia-Frank ,
Thanks for trying that too. It appears to be very tricky issue.
Btw. do you cross compile?
I do cross-compile only my plugins. I haven’t tried cross-compiling N++ but I don’t think that’s straightforward because you’ll need a CMake config (and you’ll have to create one yourself). If you decide to do so you can try automatic conversion from VS solution to CMakeList:
You will also need the cross-compiler (MinGW for x86 in my case).
ram prakash last edited by
I’m a happy camper now. for past few hours I had the exact same problem but finally after a deep research I found this article for the about puzzle please visit the below one :https://superuser.com/questions/377904/recover-file-corrupted-due-to-power-cut-off
Vinodkumar GB last edited by
An year ago issue is still persistent!
I was a big fan of this software but now after loosing some 20+ hours of work, I am devastated! Even the saved file is being NULLed! I googled another 2 hrs trying to find any help! What a waste… lesson learned…
I realize my mistake :(
Should have stuck with just notepad or any other editor!
Good bye Notepad++
guy038 last edited by guy038
So, seemingly, in some circumstances, on saving a file, N++ would just save corrupted contents, with NUL bytes, in the present version, on the HD ? Now, the problem is to find out in which circumstances this issue occurs ?!
May be, @claudia-frank and @pnedev, the part of code to examine is just when N++ is saving current file ? Indeed, as said above, after reading file and before saving it, N++, certainly, doesn’t interfere with current modified file on hard disk, if NO backup process, either, from within N++ or from outside, is presently running in the background !
May be, working with a new # tab, instead of a previously saved file, could be of importance, too ?
Some thoughts, from a non-coder ( at least in C/C++ ! ) guy !
Attila Berencsi last edited by Attila Berencsi
I had the same issue today morning starting Notepad++ 7.5.4 32 bit version, on Win 10 x64. I had no other choice just to force power off my laptop due USB problems yesterday evening. All the previously opened files/tabs closed/disappeared, and the one edited last time (not saved explicitly) corrupted. Notepad++ works the following way for my by default without any specific settings: Notepad++ is keeping the content of modified text files without saving them when closing the app. Next time I reopen NotePad++, I have the insaved contect kept without any specific settings. If I open text files with ms notepad the unsaved content in notepad++ is not visible there. In this case however the corrupted file is also corrupted in other editors.
Igor Galochkin last edited by Igor Galochkin
I’ve had this issue with corrupted files for at least a dozen times in the last 1-2 years. As far as I remember, I’ve always been able to restore the file from the “backups” folder.
But just today I’ve had it again (blue screen of Windows after some weird bugs in Android emulator, whatever) - and the “backups” of Notepad++ folder seems to have NOT been saving anything for quite a while! E.g. of the file which was corrupted (all "NULL"s) the backup copy is dated June 2017. That is, no backup of it was done in 9 months, although I was editing that file multiple times per day, every day in the last several years!
In the “backups” folder I do see some backup files, but the dates of them are scattered quite randomly and scarcely (like, 1 backup file per month). I know I’ve been editing tons of different txt files in the last months, but apparently almost none of that was backed up!
I now went ahead and set Setting->Preferences->Backup on save, Verbose Backup. Now if I try to edit some txt file and save it, nothing is created in “backups” folder. And no backups are made every 7 seconds, as the other setting says. So, apparently, both settings don’t work.
So, 2 things:
how is it even possible that the whole file would turn into NULLs if there is a power outage/blue screen and the whole Windows OS just crashes? Why on Earth is Notepad++ writing anything into the file at that point? I suppose the normal way a text editor would operate is to edit the copy of the contents of the file in RAM and only flush the contents into the actual file when you hit Save. My files are pretty small (below 1MB, even below 100KB mostly), so why would there be a need to write directly onto the disk? Still, if Windows is crashing, how does Notepad++ get a chance to save anything on disk…
the whole backups system is completely bugged now, and no backups are done no matter what the settings are.
Fortunately I do have backups of my own on Dropbox, but for the file in question the backup is 1 month old, so I will still lose quite some work, though not everything…
Frankly, this whole situation is ridiculous. It really is. I haven’t seen any editor which would not only lose recent work but instead devastate the whole file which could mean years of work.
I’m on Windows 7 64 bit, Notepad++ 7.5.4 (latest version).
Scott Sumner last edited by
I feel your pain–actually I felt it only once and I didn’t lose much (only about 2 hours of work)–but still… It is a known issue, at least to posters here on this forum–see my list of links in this thread–but I don’t know that it is getting much if any attention from developers.
There is a theory (not mine…but I can’t prove/disprove it) that having one of the backup methods turned ON causes or contributes to the chain of events that allows this data loss to occur. I know that when it happened to me (via a hardware-related BSOD) that I did indeed have Verbose backups enabled and backups were being made right up until the time of crash. Unfortunately, my experience was that all files I had changed and saved during that particular Notepad++ editing session (2 hours old) were wiped out, including all backups made during that time.
I always had my own backup plan in place, entirely separate from Notepad++'s control, which is why I didn’t lose a lot. I recommend everyone do the same…even after this issue is resolved!
PeterJones last edited by PeterJones
At one point last month, I tried using the windows API from an external process to try to kill the Notepad++ instance, and see if I could reliably replicate the issue, but I couldn’t get it to trigger; apparently, even killing the process externally is too “clean” of an exit.
Today, I began to think that maybe there was a way to force a Windows Blue Screen Of Death while running NPP, and see if it could replicate the problem – my thought was in a Virtual Machine, to protect any actual hardware.
I found this MS TechNet post which explains how to initiate a BSOD. It has a disclaimer, “you cannot manually initiate a Stop error on a virtual machine that has virtual machine extensions installed”, but that implies that a VM without extensions installed should be able to be forced to BSOD.
I don’t have a VM (or a physical machine that I could risk), nor do I have the windows-app debugging skill necessary to figure out what’s going wrong, even if I could replicate the problem reliably… but I thought I’d share the idea, in case someone else has the right tools and skillset.
(I posted this almost verbatim in the GitHub issue #2381, but thought I’d share it here, too.)
Scott Sumner last edited by
Right after the issue happened to me, I tried manually forcing some BSODs on an old machine (running Windows 7) that I don’t care so much about. I had no luck in replicating the NUL corruption thing that way, even though I was careful in my attempt to set up the exact Notepad++ configuration I had been running (fairly easy as I use the “portable” version). As my original BSOD was “hardware-related”, I couldn’t duplicate that part in the recreation…
So I like your thinking, but no-dice for me when I tried it a bit ago…