Skip to content

Commit 90dab6a

Browse files
KenoKristofferC
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 1eb4dee commit 90dab6a

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 7f4a96a353c06c2fdecb0b2464800bcf8fab6fd7
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 02ff092e..56aafa95 100644
14+
--- a/exports/dllinit.c
15+
+++ b/exports/dllinit.c
16+
@@ -48,7 +48,10 @@ BOOL APIENTRY DllMain(HINSTANCE hInst, DWORD reason, LPVOID reserved) {
17+
}
18+
19+
if (reason == 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+
}
26+
27+
return TRUE;

0 commit comments

Comments
 (0)