Skip to content

Commit 79d55f4

Browse files
committed
Fix CI hangs on win32
After much debugging, it turns out that OpenBlas is sometimes hanging on exit due to bad assumptions in its thread management. The upstream discussion is at OpenMathLib/OpenBLAS#2350, but this should fix our frequent win32 CI failures in the meantime.
1 parent 4c58369 commit 79d55f4

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

deps/blas.mk

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,12 @@ $(BUILDDIR)/$(OPENBLAS_SRC_DIR)/openblas-skylakexdgemm.patch-applied: $(BUILDDIR
9999
patch -p1 -f < $(SRCDIR)/patches/openblas-skylakexdgemm.patch
100100
echo 1 > $@
101101

102-
$(BUILDDIR)/$(OPENBLAS_SRC_DIR)/build-configured: $(BUILDDIR)/$(OPENBLAS_SRC_DIR)/openblas-skylakexdgemm.patch-applied
102+
$(BUILDDIR)/$(OPENBLAS_SRC_DIR)/openblas-winexit.patch-applied: $(BUILDDIR)/$(OPENBLAS_SRC_DIR)/source-extracted
103+
cd $(BUILDDIR)/$(OPENBLAS_SRC_DIR) && \
104+
patch -p1 -f < $(SRCDIR)/patches/openblas-winexit.patch
105+
echo 1 > $@
106+
107+
$(BUILDDIR)/$(OPENBLAS_SRC_DIR)/build-configured: $(BUILDDIR)/$(OPENBLAS_SRC_DIR)/openblas-skylakexdgemm.patch-applied $(BUILDDIR)/$(OPENBLAS_SRC_DIR)/openblas-winexit.patch-applied
103108
echo 1 > $@
104109

105110
$(BUILDDIR)/$(OPENBLAS_SRC_DIR)/build-compiled: $(BUILDDIR)/$(OPENBLAS_SRC_DIR)/build-configured

deps/patches/openblas-winexit.patch

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
commit 67bdd1b07c8fe880b2813c96849444b3dea67860
2+
Author: Keno Fischer <keno@juliacomputing.com>
3+
Date: Sun Dec 29 15:08:13 2019 -0500
4+
5+
win32: Don't run cleanup if we're about to exit anyway
6+
7+
If the process is about to exit, there's no point trying to do
8+
a bunch of work to clean up resources. The kernel will release
9+
them much more efficiently when the process exits at the end
10+
of this function.
11+
12+
diff --git a/exports/dllinit.c b/exports/dllinit.c
13+
index 02ff092e..b65fe0c6 100644
14+
--- a/exports/dllinit.c
15+
+++ b/exports/dllinit.c
16+
@@ -42,13 +42,17 @@ void gotoblas_init(void);
17+
void gotoblas_quit(void);
18+
19+
BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD reason, LPVOID reserved) {
20+
+<<<<<<< HEAD
21+
22+
if (reason == DLL_PROCESS_ATTACH) {
23+
gotoblas_init();
24+
}
25+
26+
if (reason == DLL_PROCESS_DETACH) {
27+
- gotoblas_quit();
28+
+ // If the process is about to exit, don't bother releasing any resources
29+
+ // The kernel is much better at bulk releasing then.
30+
+ if (!reserved)
31+
+ gotoblas_quit();
32+
}
33+
34+
return TRUE;

0 commit comments

Comments
 (0)