From aac968162b7636415640332f2225b637d58ae2d4 Mon Sep 17 00:00:00 2001 From: bubnikv Date: Sun, 6 Nov 2016 17:42:36 +0100 Subject: [PATCH] Unit test to verify whether Slic3r would hang when croaking from a C++ exception handler. This is an unfortunate error in some Strawberry Perl distributions. --- xs/MANIFEST | 1 + xs/t/22_exception.t | 16 ++++++++++++++++ xs/xsp/XS.xsp | 8 ++++++++ 3 files changed, 25 insertions(+) create mode 100644 xs/t/22_exception.t diff --git a/xs/MANIFEST b/xs/MANIFEST index 5a0a3e420..70d83afa7 100644 --- a/xs/MANIFEST +++ b/xs/MANIFEST @@ -166,6 +166,7 @@ t/18_motionplanner.t t/19_model.t t/20_print.t t/21_gcode.t +t/22_exception.t xsp/BoundingBox.xsp xsp/BridgeDetector.xsp xsp/Clipper.xsp diff --git a/xs/t/22_exception.t b/xs/t/22_exception.t new file mode 100644 index 000000000..ca2ffea89 --- /dev/null +++ b/xs/t/22_exception.t @@ -0,0 +1,16 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Slic3r::XS; +use Test::More tests => 1; + +{ + eval { + Slic3r::xspp_test_croak_hangs_on_strawberry(); + }; + is $@, "xspp_test_croak_hangs_on_strawberry: exception catched\n", 'croak from inside a C++ exception delivered'; +} + +__END__ diff --git a/xs/xsp/XS.xsp b/xs/xsp/XS.xsp index 9b068882c..c324396b2 100644 --- a/xs/xsp/XS.xsp +++ b/xs/xsp/XS.xsp @@ -28,4 +28,12 @@ FORK_NAME() RETVAL = newSVpv(SLIC3R_FORK_NAME, 0); OUTPUT: RETVAL +void +xspp_test_croak_hangs_on_strawberry() + CODE: + try { + throw 1; + } catch (...) { + croak("xspp_test_croak_hangs_on_strawberry: exception catched\n"); + } %} \ No newline at end of file