From 179d93f09ddb86774474a63e137656d41c85279c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Fri, 11 Mar 2016 08:23:04 +0100 Subject: [PATCH] Add test for issue #1452. TCP connection should not crash the program if they are closed from within a finalizer. Instead, give a warning if such a class has leaked. (cherry picked from commit 2c0adbc56170571991781cebf1e3aac1549828ad) --- tests/vibe.core.net.1452/dub.sdl | 3 +++ tests/vibe.core.net.1452/source/app.d | 23 +++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 tests/vibe.core.net.1452/dub.sdl create mode 100644 tests/vibe.core.net.1452/source/app.d diff --git a/tests/vibe.core.net.1452/dub.sdl b/tests/vibe.core.net.1452/dub.sdl new file mode 100644 index 0000000..28b66b5 --- /dev/null +++ b/tests/vibe.core.net.1452/dub.sdl @@ -0,0 +1,3 @@ +name "tests" +description "Invalid memory operation on TCP connection leakage at shutdown" +dependency "vibe-d:core" path="../../" diff --git a/tests/vibe.core.net.1452/source/app.d b/tests/vibe.core.net.1452/source/app.d new file mode 100644 index 0000000..c0ac16e --- /dev/null +++ b/tests/vibe.core.net.1452/source/app.d @@ -0,0 +1,23 @@ +import vibe.core.core; +import vibe.core.net; +import core.time : msecs; + +class C { + TCPConnection m_conn; + + this() + { + m_conn = connectTCP("google.com", 443); + } + + ~this() + { + m_conn.close(); + } +} + +void main() +{ + auto c = new C; + // let druntime collect c during shutdown +}