Browse code

Register signal handler to prevent crashing R on abort

Ubuntu authored on 28/03/2019 20:31:49
Showing 5 changed files

... ...
@@ -1,11 +1,11 @@
1 1
 Package: RBGL
2
-Version: 1.59.4
2
+Version: 1.59.5
3 3
 Title: An interface to the BOOST graph library
4 4
 Author: Vince Carey <stvjc@channing.harvard.edu>, Li Long
5 5
         <li.long@isb-sib.ch>, R. Gentleman
6 6
 Maintainer: Bioconductor Package Maintainer
7 7
         <maintainer@bioconductor.org>
8
-Depends: graph, methods, BH
8
+Depends: graph, methods
9 9
 Imports: methods
10 10
 Suggests: Rgraphviz, XML, RUnit, BiocGenerics
11 11
 Description: A fairly extensive and comprehensive interface to the
... ...
@@ -14,3 +14,4 @@ License: Artistic-2.0
14 14
 URL: http://www.bioconductor.org
15 15
 LazyLoad: yes
16 16
 biocViews: GraphAndNetwork, Network
17
+LinkingTo: BH
... ...
@@ -1 +1 @@
1
-PKG_CPPFLAGS=@BOOSTFLAGS@ -Dabort=_bgl_abort
1
+PKG_CPPFLAGS=@BOOSTFLAGS@ 
... ...
@@ -10,6 +10,7 @@
10 10
 #include <iterator>
11 11
 #include <algorithm>
12 12
 #include <time.h>
13
+#include <csignal>
13 14
 
14 15
 #include <boost/config.hpp>
15 16
 #include <boost/utility.hpp>
... ...
@@ -137,5 +138,9 @@ typedef R_adjacency_list<boost::undirectedS, int> Graph_ui;
137 138
 typedef R_adjacency_list<boost::directedS, double> Graph_dd;
138 139
 typedef R_adjacency_list<boost::undirectedS, double> Graph_ud;
139 140
 
141
+extern "C"  {
142
+void sigabrt_handler(int isig);
143
+}
144
+
140 145
 #endif // RBGL_RBGL_H
141 146
 
... ...
@@ -64,9 +64,11 @@ extern "C"
64 64
 		
65 65
 		std::vector<graph_traits<VEGraph>::vertex_descriptor> f(NV1);
66 66
 
67
+		signal(SIGABRT, sigabrt_handler);
67 68
 		r = isomorphism(g1, g2, isomorphism_map 
68 69
 			(make_iterator_property_map(f.begin(), v1_index_map, f[0])));
69 70
 		}
71
+		signal(SIGABRT, SIG_DFL);
70 72
 
71 73
 		SEXP ansList, conn;
72 74
 		PROTECT(ansList = Rf_allocVector(VECSXP,1));
73 75
similarity index 70%
74 76
rename from src/kludge.cpp
75 77
rename to src/registerSigHandlers.cpp
... ...
@@ -1,13 +1,9 @@
1
+#include "RBGL.hpp"
1 2
 #include <Rdefines.h>
2
-// #include "kludge.hpp"
3 3
 
4 4
 extern "C"  {
5
-void _bgl_abort()
6
-{
5
+void sigabrt_handler(int isig) {
7 6
     Rf_error
8 7
         ("internal: RBGL invoked 'abort'; see warnings() and restart R");
9 8
 }
10 9
 }
11
-
12
-
13
-