Slashdot Mirror


Data Loss Bug In OS X 10.5 Leopard

An anonymous reader writes "Leopard's Finder has a glaring bug in its directory-moving code, leading to horrendous data loss if a destination volume disappears while a move operation is in progress. This author first came across it when Samba crashed while he was moving a directory from his desktop over to a Samba mount on his FreeBSD server."

33 of 603 comments (clear)

  1. Tiger has this problem as well!!! by itsybitsy · · Score: 5, Informative

    I lost a huge amount of data being MOVED (not copied) from one volume into a virtual volume DMG file. Lost and gone forever, lots of important files. What happened? I simply bumped the laptop Mac Book Pro during the move... zap... gone forever. The DMG file was blank! Yes, complely zero bytes except for a bit of header non-file data. It sucks bad.

  2. Terrible bug by thegrassyknowl · · Score: 2, Informative

    But entirely fixable.

    Knowing it exists means you can also work around it by doing copies every time and only manually deleting the source entry when you're sure the copy has completed properly. Now all you need to do is be mindful every time you want to move a file anywhere.

    Sucks to be a Mac user (I am one, I know) but I'm sure Apple will have this fixed pretty quick.

    --
    I drink to make other people interesting!
    1. Re:Terrible bug by RobertM1968 · · Score: 3, Informative

      Error code 51 doesnt neccesarily mean the transfer failed. It can also mean lost connection to the share - which could have happened (in OSX's "mind") after it thought/was told the transfer was complete.

      For instance, what if in stopping the share on the Windows session (incorrectly listed in the /. article as a FreeBSD Share), the SMB crap in Windows is "cleaning up" while shutting down and generating a "complete" code that it sends back to the Apple machine, which then in trying to communicate with the share, realizes it no longer can, and generates the correct error code as noted (51).

      OSX did NOT generate a disk write error or any other error that would have been more applicable (like 43 or a bunch of other possibilities). It generated an error stating it lost communication with the other machine.

      Again, still not enough info without knowing more about what the WinShare does when closed.

    2. Re:Terrible bug by Pliep · · Score: 3, Informative

      Actually, Time Machine runs every two minutes. You can see a countdown timer in the system preferences. Also, Time Machine is dodgy by itself. Apple confirms that after backing up about 10 GB of data, Time Machine may stop working. See here: http://docs.info.apple.com/article.html?artnum=306932

  3. Par for the course? by GoRK · · Score: 5, Informative

    No offense meant here, but normal move/copy operations are traditionally highly destructive events on MacOS anyway. For instance there is absolutely no simple way to merge two folders contents together on the mac. If you drag a folder called "Documents" into your home directory and click on "OK", the Mac OS will happily delete your entire documents folder. I was reminded of this enormous frustration while recovering from some multi-volume backups recently, having to resort to an obscure OS X commandline tool 'pax' and Leopard's newfound support of hardlinks to make some simple file copies play nice and not unnecessarily consume 3 times the disk space they should have.

    For all of the flack the Windows file copy interface gets, it is both safer and more flexible than trying to use the Finder: an interface that makes file management so stupefying it becomes impossible.

    1. Re:Par for the course? by Just+Some+Guy · · Score: 2, Informative

      having to resort to an obscure OS X commandline tool 'pax'

      Pax isn't an OS X tool tool any more than tar is - just an FYI. Also, learn to love rsync. It would've done what you described in a breeze (at least when compared with other command-line tools).

      --
      Dewey, what part of this looks like authorities should be involved?
    2. Re:Par for the course? by TheNetAvenger · · Score: 4, Informative

      I haven't noticed different behavior in any version of Windows. How do you merge similarly named folders during a copy/move in Windows? In my experience you get the same "Do you want to replace this?" type prompt you get in OS X.


      Serious answer...

      XP offers a basic, do you want to replace folder and a basic do you want to replace files. (Very generic, but more than OS X does)

      Vista on the other hand, asks if you want to replace/merge folder and then if conflicting files are found in the folders it asks you if you want to overwrite the files, don't overwrite them, or create a second copy of the file in the same folder. File by File and Folder by Folder if you want, or you can hit a check box to mimic your response for all file and folders if you are moving a lot of files/folders.

      It also will show you the two versions of the file or folder so you can make a decision based on which files/folders are newer, and you even get a thumbnail of the file for documents and pictures to be sure you are keeping the one you want.

      (Very simple interface, but more has the functionality of the power geek that was always left to using tools like XCopy in the past.)

      This is one of the 'little' Vista features that doesn't get any press, but is a lifesaver for people that move around a lot of data, as you can merge and update folders and files much easier.

      Stuff like this is the reason I said if MS did a 'new features' list like the pety list Apple did with their 300 new features, Vista would have several thousand new features to list.

      (Again MS's marketing sucks, since most people don't even know stuff like this exists in Vista, and it is both powerful, easy, and just works.)

  4. Re:That's silly. by Hatta · · Score: 5, Informative

    Why don't you just use rsync?

    --
    Give me Classic Slashdot or give me death!
  5. Re:That's silly. by Frothy+Walrus · · Score: 5, Informative

    Oh yeah, rsync. Is that one still broken on 10.5? Apple's build of rsync on 10.4 consistently choked on a few files when my dad started using it on his Mac Pro.

  6. Re:That's silly. by doxology · · Score: 3, Informative

    then some metadata on the disk is modified to reflect your move.

    --
    sigfault. core dumped.
  7. Re:That's silly. by ackthpt · · Score: 5, Informative

    So what happens if you're moving a 120GB folder one directory level on a 150GB disk?

    Typically if you are moving within the same logical device the file pointer is moved and no copying need take place.

    When moving to another device your code reads and writes, within a loop and traps exceptions (such as the device suddenly vanished, where the OS should raise an exception and your application traps it.) A wide variety of errors could occur while moving and in the event any of them happen the user should be notified in an appropriate manner and the original data not deleted.

    I've written a number of applications which moved files or data between databases and it's fundamental your application is on the watch for any problems. Not to have an exception raised or to trap any and all, well, that's simply an inexcusable lapse.

    This sort of thing is extremely critical if you happend to be defragmenting a disk drive. Long before Macs and PCs we had to defrag our mainframe drives and the applications which did the work were quite careful. Often the best practice, if you had the resource of a second drive, was to simply defrag to a new drive then re-assign the new dist as the original.

    --

    A feeling of having made the same mistake before: Deja Foobar
  8. Not default behavior by Have+Blue · · Score: 3, Informative

    Someone should point out that by default, the Finder will copy files dragged to a different volume. You have to hold down a modifier (Command) to force a move operation. So while this is a severe bug that should be fixed immediately, it's much less likely to happen by accident than the article implies.

  9. Re:I don't understand by t35t0r · · Score: 5, Informative

    NFS write failure on Linux 2.4, check your data is gone.

    Uhh no. In linux mv's always make sure the data moved then delete the original file (as far back as 2.4). You can test this by dd'ing a large file (use if=/dev/urandom), then run a md5sum on it, then do a mv within the same drive, over nfs, over samba/cifs, to floppy (not sure what happens here because linux caches writes to floppies until umount), to usb drive, whatever. While the mv is in operation just pull the plug on the system (target or source system). Your old file will still be there!

  10. Re:No it isn't by tf23 · · Score: 4, Informative

    You have to pay to be able to participate in the program

    Wrong-o!! You absolutely do not have to pay anything to involved in the Appleseed program.

  11. Not just 10.5 by rir · · Score: 2, Informative

    This has been standard Mac OS operation for a long time. I know for sure that the same happens under OSX 10.4, and as I recall, older versions of the Mac OS (7/8/9) all did the same thing. Granted this is a stupid way of implementing file moving, the alarmist headline is a little unnecessary.

  12. Re:Ah, the "outsourcing" coding model.. by beav007 · · Score: 5, Informative

    Um... no. REALLY no. Please don't do that.

    The syntax for "||" is:
    If command 1 fails, do command 2 - otherwise exit (where you used "command1 || command2").

    In this case, your command will either copy all the files from $from to $to or delete all files at $from.

    What you probably meant is cp $from $to && rm -r $from, which only performs the second command if the first succeeded. This solution is far from perfect for reasons mentioned by other posters, but it's still significantly safer and more useful than yours...

  13. Re:"haha" by gsking1 · · Score: 2, Informative

    In case you are serious about this question - I believe it is a reference to the Simpsons. A quick google found this...http://www.allposters.com/-sp/Nelson-Posters_i424903_.htm

  14. File The Bug!! by EccentricAnomaly · · Score: 3, Informative

    Go Here: http://developer.apple.com/bugreporter/ And File a bug. And They'll fix it.

    --
    There are 10 types of people in this world, those who can count in binary and those who can't.
  15. Re:Data deletion in Mac OS X by w3woody · · Score: 2, Informative

    That behavior is by design and has been the way Apple handles directory overwrites since 1985.

  16. Re:I don't understand by crabpeople · · Score: 2, Informative

    "Network error moving from one windows box to another, yep your data is gone."

    Have you ever used a computer? Youre quite simply wrong. Ive had many move operations fail and never lost a file doing it. You can test by moving a large file, pulling the network cable out. The file is still on your PC. With your "bad disk" example, well yeah if the disk lies to the OS saying that files are copied when theyre not then that could happen. This would be very rare as bad disks tend to advertise rather loudly (to the OS) that they are going bad.

    --
    I'll just use my special getting high powers one more time...
  17. Re:I don't understand by Anonymous Coward · · Score: 1, Informative

    You're an idiot. I have been using Linux for 15 years. I have had network shares die and even drives die while moving files in Linux and not once have I lost the originals.

    In fact if you use verbose mode with mv you can see exactly what it's doing and it doesn't delete the old file until it confirms the new version was successfully copied. This is for volume-to-volume transfers, a move on the same volume is instantaneous and generally can not fail for most file systems (ext, xfs, etc).

  18. I had this happening to me with WinXP aswell by Lisandro · · Score: 4, Informative

    That's it, moving a file, network failure and poof, moved files deleted from the source. Most probably a bizarre coincidence, but after it happened a few times i now copy and then delete when working on a SMB network.

    (Or maybe Samba has something to do with it?)

  19. Re:That's silly. by v1 · · Score: 2, Informative

    right now version 2.6.0 is the only one worth using. It still can't copy pipes, and isn't smart enough to set ownership on symbolic links, but it doesn't mangle anything else.

    You have to be using 2.6.0 on both ends too.

    --
    I work for the Department of Redundancy Department.
  20. Re:That's silly. by passion · · Score: 2, Informative

    You want the resource fork... from Apple's rsync manpage: -E --extended-attributes copy extended attributes, resource forks

    --
    - passion
  21. Re:Problems by Daengbo · · Score: 3, Informative

    How can you have a 5-digit UID and still have never seen the 17MB troll? Did you buy your account on ebay? P200. How old do you think the troll is?

  22. Re:Or [possibly], go fix it. by andreyw · · Score: 4, Informative

    Finder, and any GUI parts of OS X in general, are not part of Darwin.

  23. Re:Ah, the "outsourcing" coding model.. by BKX · · Score: 2, Informative

    Actually I meant this but posted too soon. It pretty much guards against most things (the shell will do all the escaping necessary). The only thing i foresee a problem with is if names that are legal on one filesystem that are illegal on the other. I don't think rsync takes care of the either.

    cp -aRp "$from" "$to" && rm -r "$from"

  24. Re:That's silly. by Matt+Perry · · Score: 4, Informative

    I think you misunderstand something.
    No, I understand perfectly.

    I know for a fact that I've successfully canceled FTP-moves on Windows (brand); I also know for a fact that I've successfully canceled FTP-moves on all modern instances of the Windows OS with various FTP clients (programs).
    I'm not talking about other clients. I'm talking about using Windows XP as the client.

    What program were you using that fragged your FTP server directory exactly?
    Windows XP, service pack 1.

    I suspect you're a fud-fucking idiot
    You need to work on your social skills.

    although at the moment, I'm interested to hear if there's more than fabrication here. Pray tell: how can I reproduce this bug?
    You might need to use WinXP service pack 1. I'm unable to reproduce it now on my home machine which has SP2 installed. At work we've just upgraded to service pack 2 within the last six months. Anyway, about a year ago I was trying to move nearly 40 gigs of data from a Solaris server at another site to my local machine. The Solaris server was an FTP server and that's the only access I had to it. I opened Internet Explorer and typed in ftp://servername and was prompted for a username and password which I entered. Then I saw the files in the explorer view just like I see files on my local machine. Since I was moving so much data I decided to do it one top-level directory at a time. To move the files I selected the folder, dragged it to a folder on my local machine, and held down shift when I let go of the mouse pointer so it would move instead of copy. I noticed that Windows went through three steps when it moved from the FTP site:
    1. A dialog appears with the title Moving... and it says it's calculating how much time it'll take. This took a while itself.
    2. Then the dialog says it's moving the files and the progress meter shows the progress
    3. After the progress meter fills up, it goes to empty again and then says it's deleting the files it moved
    I did this with most of the folders until I reached one that had about 18GB of data in it. I performed the same procedure as above to start the move and after it was copying files for about a minute or two I realized that I was moving them to the wrong location (my desktop instead of a directory on my C drive). At work our desktops are retargeted to a file server and not our local hard drives. I knew that by copying to the desktop I would hit my quota limit on the server whereas if I had copied to the C drive like I did with the other folders I had no limit aside from the free hard drive space. Not copying there in the first place was just a mistake. I clicked cancel to stop the transfer. When I did that, the dialog that had the progress bar changed to the empty progress bar and said it was now deleting. By the time I realized what was going on, it had deleted that folder and all of its content from the FTP site.

    Now this could have been some weird bug or interaction between the fact that I was using a machine with SP1 instead of SP2, that my desktop and profile were retargeted to another machine, or that I was moving so much data. It wasn't a lot of files as these were data files for desktop publish programs for some brochures and catalogs, along with large print-ready images. I don't know what items worked together to cause the problem. I do know that it did happen and that I had to deal with the IT group at our other site (that had the Solaris server), open the helpdesk ticket to get them to restore the files from backup, wait for them to get around to it, etc. It was a huge pain and delayed what I was working on, causing grief for myself and my internal customer. One thing's for sure; I'll never use the built-in Windows FTP client again.
    --
    Slashdot: Failed Car Analogies. Amateur Lawyering. Anecdote Battles.
  25. Re:No it isn't by JEB_eWEEK · · Score: 3, Informative
    Not quite.

    How can I sign up for this program?

    We are not seeking new participants. You must have an invitation in order to log in.

    https://appleseed.apple.com/cgi-bin/WebObjects/SeedPortal.woa/wa/faq

    OR, there's:

    Become an ADC Select Member US$499.00

    Upon purchase and activation, you'll receive:

    * ADC Software Seeding Program

    http://developer.apple.com/products/select.html
  26. Re:That's silly. by kisielk · · Score: 5, Informative

    There have been resource fork patches for some time, but somewhat unreliable. Version 3.0 is going to support resource forks (and other types of extended attributes) out of the box. The setup we have been using extracts resource forks to a separate file on the mac and then backs them up alongside the original files. The restore process just performs the reverse. It will be nice once we can switch to rsync 3.0 and get rid of that step.

  27. osx ? by l3v1 · · Score: 2, Informative

    I don't think this is an OSX specific bug. Just this weekend I moved some video files over from a Windows desktop pc to my also Windows media pc (Windows based custom box) to a shared folder, then I went out for a tea, came back in, and I forgot the move was in process, and I switched off the media pc. About half an hour later I went back to my desktop pc, to see an error message about a failed write, then all the files I wanted to move have been deleted from the desktop pc. Checking the media pc, the first file was there, but damaged.

    --
    I am putting myself to the fullest possible use, which is all I can think that any conscious entity can ever hope to do.
  28. This may not get read, but still by analog_line · · Score: 3, Informative

    This is a bug with the FINDER ONLY, just so everyone is clear. The Unix "mv" command in Leopard is NOT affected by this.

    http://www.macintouch.com Obviously this is the front page story today.

    This only affects "move" operations between logical volumes. You have to hold down Command while you're doing this, inside the Finder, to get this to happen. Yes, it's a bad bug. It's not something, however, that you're going to run into if you're thinking sensibly about how you treat important data, or if you didn't know that the Command-drag functionality was built into the Finder (which I didn't, and I can't think of a time when I would use it now that I do, even if it was working correctly).

  29. Re:No it isn't by jeremyp · · Score: 2, Informative

    The Finder is not open source and the problem is in the Finder.

    FYI the kernel has a syscall called rename which only works if both source and destination are on the same file system. If they are not, it fails and sets errno to EXDEV. Moves between file systems are simulated by userland programs doing a copy then a delete. I'm pretty sure that cp issues a rename and then falls back to copy-delete if it gets EXDEV back. The Finder must already know that the destination is on a different file system because default behaviour is to copy when a file is dragged onto a different file system and move iif it is dragged onto the same file system.

    --
    All I want is a secure system where it's easy to do anything I want. Is that too much to ask ~~ Randall Munroe