Skip to content

Commit 5ec4257

Browse files
Kenostaticfloat
authored andcommitted
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 eb8b8cf commit 5ec4257

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

deps/blas.mk

+6-1
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

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
commit b16fa2e7111dc4dc1d9d987bd5dcbf89c82b9ee8
2+
Author: Keno Fischer <[email protected]>
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 4a05c0e1..88f9af65 100644
14+
--- a/exports/dllinit.c
15+
+++ b/exports/dllinit.c
16+
@@ -50,7 +50,10 @@ BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD reason, LPVOID reserved) {
17+
gotoblas_init();
18+
break;
19+
case DLL_PROCESS_DETACH:
20+
- gotoblas_quit();
21+
+ // If the process is about to exit, don't bother releasing any resources
22+
+ // The kernel is much better at bulk releasing then.
23+
+ if (!reserved)
24+
+ gotoblas_quit();
25+
break;
26+
case DLL_THREAD_ATTACH:
27+
break;

0 commit comments

Comments
 (0)