From 371efd85ec1660e57175150d9f71b16741b89aa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Tue, 10 Sep 2024 11:01:49 +0200 Subject: [PATCH 1/5] Fix unit test compile error on certain intermediate versions of DMD. Currently leads to CI errors in the vibe.d repository, because 2.096.1 hasn't been tested here. --- .github/workflows/test.yml | 1 + source/vibe/internal/async.d | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 426027c..cf327fa 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,6 +21,7 @@ jobs: dc: [dmd-latest, ldc-latest] arch: [x86_64] include: + - { os: ubuntu-latest, dc: dmd-2.096.1, arch: x86_64 } - { os: windows-latest, dc: dmd-2.092.0, arch: x86_64 } - { os: windows-latest, dc: dmd-2.092.0, arch: x86_mscoff } - { os: windows-latest, dc: dmd-2.091.1, arch: x86_64 } diff --git a/source/vibe/internal/async.d b/source/vibe/internal/async.d index 2dd70d9..a8f1bf8 100644 --- a/source/vibe/internal/async.d +++ b/source/vibe/internal/async.d @@ -258,7 +258,7 @@ private template hasAnyScopeParameter(Callback) { else enum hasAnyScopeParameter = any!(c => c & ParameterStorageClass.scope_)([SC]); } -static if (is(noreturn)) // issue 299, requires newer host compilers +static if (is(noreturn)) static if (is(ReturnType!(() => assert(0)) == noreturn)) // issue 299, requires newer host compilers version (unittest) { alias CB = noreturn delegate(int) @safe nothrow; alias wait = delegate noreturn(_) => assert(0); From 21f8b31a7d7ebe33a33208f91c5f01a4ee07ada3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Tue, 10 Sep 2024 11:02:11 +0200 Subject: [PATCH 2/5] Avoid using "in" parameter to avoid linker error caused by compiler bug. --- source/vibe/core/task.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/vibe/core/task.d b/source/vibe/core/task.d index 6c9f214..fd68144 100644 --- a/source/vibe/core/task.d +++ b/source/vibe/core/task.d @@ -39,7 +39,7 @@ struct Task { m_taskCounter = task_counter; } - this(in Task other) + this(const Task other) @safe nothrow { m_fiber = () @trusted { return cast(shared(TaskFiber))other.m_fiber; } (); m_taskCounter = other.m_taskCounter; From e1358b8a944835e35a206978d067a584527c4fc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Tue, 10 Sep 2024 11:22:41 +0200 Subject: [PATCH 3/5] Comment out the libasync configuration to follow suit with eventcore. --- dub.sdl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dub.sdl b/dub.sdl index b6210be..bedef09 100644 --- a/dub.sdl +++ b/dub.sdl @@ -28,9 +28,9 @@ configuration "select" { subConfiguration "eventcore" "select" versions "Windows7" platform="windows" } -configuration "libasync" { - subConfiguration "eventcore" "libasync" -} +//configuration "libasync" { +// subConfiguration "eventcore" "libasync" +//} buildType "unittest" { buildOptions "unittests" "debugMode" "debugInfo" From 9b68d42fe1fb6323beaab11c9c9c6560eb6438f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Tue, 10 Sep 2024 11:58:29 +0200 Subject: [PATCH 4/5] Make RAII style cleanup of FileStream more robust. Ensures that the close operation has finished before returning from the destructor in order to ensure the owning thread doesn't terminate prematurely, resulting in a crash. This fixes Windows CI failures. --- source/vibe/core/file.d | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source/vibe/core/file.d b/source/vibe/core/file.d index cb2ff1b..4680b7d 100644 --- a/source/vibe/core/file.d +++ b/source/vibe/core/file.d @@ -699,6 +699,13 @@ scope: ~this() nothrow { + if (this.isOpen) { + if (m_ctx.driver is (() @trusted => cast(shared)eventDriver)()) { + try close(); + catch (Exception e) logException(e, "Closing unclosed FileStream during destruction failed"); + } else logWarn("Destroying FileStream that is still open in a foreign thread (leaked to GC?). This may lead to crashes."); + } + if (m_fd != FileFD.invalid) releaseHandle!"files"(m_fd, m_ctx.driver); } From e871fbe9cbcfcbf430b39c77131e8826ed4e9917 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Tue, 10 Sep 2024 16:03:12 +0200 Subject: [PATCH 5/5] Explicitly close the output stream in SyslogLogger. Avoids relying on closing the stream through RAII, which acts worse in terms of error reporting in the presence of in-flight exceptions. --- source/vibe/core/log.d | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/vibe/core/log.d b/source/vibe/core/log.d index e5e85cc..8c67421 100644 --- a/source/vibe/core/log.d +++ b/source/vibe/core/log.d @@ -833,7 +833,6 @@ final class SyslogLogger(StreamCallback) : Logger @safe nothrow { ubyte[4096] buf; - try { auto ostr = m_streamCallback(); @@ -846,6 +845,8 @@ final class SyslogLogger(StreamCallback) : Logger while (m_buffer.empty) { if (m_buffer.capacity == 0) { ostr.finalize(); + static if (is(typeof(ostr.close()))) + ostr.close(); return; } () @trusted { m_bufferCondition.wait(); } ();