Bug 874148 - crash in libxul.so!mozilla::hal_impl::GonkDiskSpaceWatcher::OnFileCanReadWithoutBlocking [GonkDiskSpaceWatcher.cpp : 238 + 0x4]. r=fabrice
authorFernando Jiménez <ferjmoreno@gmail.com>
Mon, 27 May 2013 18:35:27 +0200
changeset 133066 67ab06eeb62f22486656e210c3aaf959ea1a2372
parent 133038 ac3784f25f7ac68997e649c2366b63e676f05f16
child 133067 5b583494d6ce5ab485cde515042ebfa91905715f
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersfabrice
bugs874148
milestone24.0a1
Bug 874148 - crash in libxul.so!mozilla::hal_impl::GonkDiskSpaceWatcher::OnFileCanReadWithoutBlocking [GonkDiskSpaceWatcher.cpp : 238 + 0x4]. r=fabrice
hal/gonk/GonkDiskSpaceWatcher.cpp
--- a/hal/gonk/GonkDiskSpaceWatcher.cpp
+++ b/hal/gonk/GonkDiskSpaceWatcher.cpp
@@ -227,18 +227,23 @@ GonkDiskSpaceWatcher::OnFileCanReadWitho
   char buf[4096];
   struct statfs sfs;
   int32_t len, rc;
 
   do {
     len = read(aFd, buf, sizeof(buf));
   } while(len == -1 && errno == EINTR);
 
+  // Bail out if the file is busy.
+  if (len < 0 && errno == ETXTBSY) {
+    return;
+  }
+
   // We should get an exact multiple of fanotify_event_metadata
-  if (len <= 0 || (len % sizeof(*fem) != 0)) {
+  if (len <= 0 || (len % FAN_EVENT_METADATA_LEN != 0)) {
     printf_stderr("About to crash: fanotify_event_metadata read error.");
     MOZ_CRASH();
   }
 
   fem = reinterpret_cast<fanotify_event_metadata *>(buf);
 
   while (FAN_EVENT_OK(fem, len)) {
     rc = fstatfs(fem->fd, &sfs);