Index: /trunk/src/kmk/dir-nt-bird.c
===================================================================
--- /trunk/src/kmk/dir-nt-bird.c	(revision 3202)
+++ /trunk/src/kmk/dir-nt-bird.c	(revision 3203)
@@ -77,5 +77,5 @@
 PKFSCACHE   g_pFsCache = NULL;
 /** Number of times dir_cache_invalid_missing was called. */
-static KU32 g_cInvalidates = 0;
+static KU32 volatile g_cInvalidates = 0;
 /** Set by dir_cache_volatile_dir to indicate that the user has marked the
  * volatile parts of the file system with custom revisioning and we only need to
@@ -651,8 +651,8 @@
  *
  * Used by $(dircache-ctl invalidate)
+ * @note    Multi-thread safe.
  */
 void dir_cache_invalid_all(void)
 {
-    assert(GetCurrentThreadId() == g_idMainThread);
     g_cInvalidates++;
     kFsCacheInvalidateAll(g_pFsCache);
@@ -663,8 +663,8 @@
  *
  * Used by $(dircache-ctl invalidate-missing)
+ * @note    Multi-thread safe.
  */
 void dir_cache_invalid_missing(void)
 {
-    assert(GetCurrentThreadId() == g_idMainThread);
     g_cInvalidates++;
     kFsCacheInvalidateAll(g_pFsCache);
@@ -675,8 +675,8 @@
  *
  * Used by $(dircache-ctl invalidate-missing)
+ * @note    Multi-thread safe.
  */
 void dir_cache_invalid_volatile(void)
 {
-    assert(GetCurrentThreadId() == g_idMainThread);
     g_cInvalidates++;
     if (g_fFsCacheIsUsingCustomRevision)
Index: /trunk/src/kmk/w32/winchildren.c
===================================================================
--- /trunk/src/kmk/w32/winchildren.c	(revision 3202)
+++ /trunk/src/kmk/w32/winchildren.c	(revision 3203)
@@ -1641,4 +1641,46 @@
 
 /**
+ * Temporary workaround for seemingly buggy kFsCache.c / dir-nt-bird.c.
+ *
+ * Something is not invalidated / updated correctly!
+ */
+static BOOL mkWinChildcareWorkerIsRegularFileW(PWINCHILDCAREWORKER pWorker, wchar_t const *pwszPath)
+{
+    BOOL fRet = FALSE;
+#ifdef KMK
+    if (utf16_regular_file_p(pwszPath))
+        fRet = TRUE;
+    else
+#endif
+    {
+        /* Don't believe the cache. */
+        DWORD dwAttr = GetFileAttributesW(pwszPath);
+        if (dwAttr != INVALID_FILE_ATTRIBUTES)
+        {
+            if (!(dwAttr & FILE_ATTRIBUTE_DIRECTORY))
+            {
+#ifdef KMK
+                extern void dir_cache_invalid_volatile(void);
+                dir_cache_invalid_volatile();
+                if (utf16_regular_file_p(pwszPath))
+                    MkWinChildError(pWorker, 1, "kFsCache was out of sync! pwszPath=%S\n", pwszPath);
+                else
+                {
+                    dir_cache_invalid_all();
+                    if (utf16_regular_file_p(pwszPath))
+                        MkWinChildError(pWorker, 1, "kFsCache was really out of sync! pwszPath=%S\n", pwszPath);
+                    else
+                        MkWinChildError(pWorker, 1, "kFsCache is really out of sync!! pwszPath=%S\n", pwszPath);
+                }
+#endif
+                fRet = TRUE;
+            }
+        }
+    }
+    return fRet;
+}
+
+
+/**
  * Tries to locate the image file, searching the path and maybe falling back on
  * the shell in case it knows more (think cygwin with its own view of the file
@@ -1746,9 +1788,5 @@
             }
 
-#ifdef KMK
-            if (utf16_regular_file_p(pwszPath))
-#else
-            if (GetFileAttributesW(pwszPath) != INVALID_FILE_ATTRIBUTES)
-#endif
+            if (mkWinChildcareWorkerIsRegularFileW(pWorker, pwszPath))
             {
                 *pfProbableClExe = mkWinChildIsProbableClExe(pwszPath, cwcPath + 4 - 1);
@@ -1764,5 +1802,5 @@
                 pwszPath[cwcPath - 1] = L'\0';
 #ifdef KMK
-                if (utf16_regular_file_p(pwszPath))
+                if (mkWinChildcareWorkerIsRegularFileW(pWorker, pwszPath))
 #endif
                 {
@@ -1837,8 +1875,4 @@
                 if (cwcComponent > 0 && cwcCombined <= MKWINCHILD_MAX_PATH)
                 {
-#ifndef KMK
-                    DWORD dwAttribs;
-#endif
-
                     /* Copy the component into wszPathBuf, maybe abspath'ing it. */
                     DWORD  cwcAbsPath = 0;
@@ -1892,11 +1926,5 @@
                         wszPathBuf[cwcCombined + 3] = L'\0';
                     }
-#ifdef KMK
-                    if (utf16_regular_file_p(wszPathBuf))
-#else
-                    dwAttribs = GetFileAttributesW(wszPathBuf);
-                    if (   dwAttribs != INVALID_FILE_ATTRIBUTES
-                        && !(dwAttribs & FILE_ATTRIBUTE_DIRECTORY))
-#endif
+                    if (mkWinChildcareWorkerIsRegularFileW(pWorker, wszPathBuf))
                     {
                         *pfProbableClExe = mkWinChildIsProbableClExe(wszPathBuf, cwcCombined + (fHasExeSuffix ? 0 : 4) - 1);
@@ -1907,5 +1935,5 @@
                         wszPathBuf[cwcCombined - 1] = L'\0';
 #ifdef KMK
-                        if (utf16_regular_file_p(wszPathBuf))
+                        if (mkWinChildcareWorkerIsRegularFileW(pWorker, wszPathBuf))
 #endif
                         {
