Community
    • Login

    Fix corrupted txt file (NULL)

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    corruptedfixtextnullfile
    114 Posts 37 Posters 144.4k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • wisemike2W
      wisemike2
      last edited by

      Notepad v7.2.2 (32 bit)
      and ya, the files were being modified at the moment of the crash.

      1 Reply Last reply Reply Quote 0
      • pnedevP
        pnedev
        last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • pnedevP
          pnedev
          last edited by

          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 KilbornA 1 Reply Last reply Reply Quote 1
          • Alan KilbornA
            Alan Kilborn @pnedev
            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 FrankC 1 Reply Last reply Reply Quote 0
            • Claudia FrankC
              Claudia Frank @Alan Kilborn
              last edited by

              @Alan-Kilborn

              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.

              Cheers
              Claudia

              1 Reply Last reply Reply Quote 1
              • pnedevP
                pnedev
                last edited by

                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.

                BR

                1 Reply Last reply Reply Quote 2
                • wisemike2W
                  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.

                  1 Reply Last reply Reply Quote 0
                  • pnedevP
                    pnedev
                    last edited by

                    One update - I tried the scenario on native Windows 7 and the issue did not appear.
                    It’s getting even more weird…

                    1 Reply Last reply Reply Quote 0
                    • pnedevP
                      pnedev
                      last edited by

                      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 FrankC 1 Reply Last reply Reply Quote 0
                      • Claudia FrankC
                        Claudia Frank @pnedev
                        last edited by

                        @pnedev

                        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?

                        Cheers
                        Claudia

                        1 Reply Last reply Reply Quote 1
                        • pnedevP
                          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:
                          https://cmake.org/Wiki/CMake#Visual_Studio.
                          You will also need the cross-compiler (MinGW for x86 in my case).

                          BR

                          1 Reply Last reply Reply Quote 1
                          • ram prakashR
                            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

                            1 Reply Last reply Reply Quote 1
                            • Vinodkumar GBV
                              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++

                              1 Reply Last reply Reply Quote 0
                              • guy038G
                                guy038
                                last edited by guy038

                                Hi All,

                                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 !

                                Cheers,

                                guy038

                                1 Reply Last reply Reply Quote 0
                                • Attila BerencsiA
                                  Attila Berencsi
                                  last edited by Attila Berencsi

                                  Hi All,
                                  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.
                                  Best regards
                                  Attila

                                  1 Reply Last reply Reply Quote 0
                                  • Igor GalochkinI
                                    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:

                                    1. 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…

                                    2. 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 SumnerS 1 Reply Last reply Reply Quote 1
                                    • Scott SumnerS
                                      Scott Sumner @Igor Galochkin
                                      last edited by

                                      @Igor-Galochkin

                                      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!

                                      1 Reply Last reply Reply Quote 2
                                      • PeterJonesP
                                        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 SumnerS 1 Reply Last reply Reply Quote 2
                                        • Scott SumnerS
                                          Scott Sumner @PeterJones
                                          last edited by

                                          @PeterJones

                                          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…

                                          1 Reply Last reply Reply Quote 1
                                          • Igor GalochkinI
                                            Igor Galochkin
                                            last edited by Igor Galochkin

                                            @Scott Sumner
                                            Just today I found out that Dropbox (even the free account of it) saves versions of files, so it kind of acts like a version control system (e.g. SVN), but you don’t have to do manual commits - any time you save the file, Dropbox stores another version of the file. I suppose on the backend they have some SVN-like implementation of this functionality (saving only the changes), but to the user it just looks like separate, chronologically listed versions of the file. Even if Dropbox doesn’t keep the versions for long, or has a limit on the combined size of all the versions, it’s still an excellent defense vs these sudden power outages or blue screens. Because after the computer restart one surely will still have the few copies just before the outage in Dropbox (plus the last NULL-filled copy).
                                            So, yeah, setting Dropbox to start together with Windows is important then.
                                            And btw one doesn’t even have to keep all the important files in the Dropbox folder. Instead, one can create a “junction” for the most important files or folders (https://www.dropboxwiki.com/tips-and-tricks/sync-other-folders).
                                            Lesson learnt :)

                                            1 Reply Last reply Reply Quote 2
                                            • First post
                                              Last post
                                            The Community of users of the Notepad++ text editor.
                                            Powered by NodeBB | Contributors