Mercurial > hg > orthanc-book
annotate Sphinx/source/faq/crash.rst @ 241:f277d18e8d71
link to debug plugins
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 29 Apr 2019 10:36:13 +0200 |
parents | ea82efa0885a |
children | 26b0d7ece4af |
rev | line source |
---|---|
239 | 1 .. _crash: |
2 | |
3 Crash analysis | |
4 ============== | |
5 | |
6 If you experience a crash within Orthanc (or one of its plugins), that | |
7 the troubleshooting sections (cf. :ref:`here <troubleshooting>` and | |
8 :ref:`here <dicom>`) do not help, and that you can't provide a robust | |
9 way to reproduce your issue by third-party developers, you'll have to | |
10 analyze the backtrace of Orthanc. | |
11 | |
12 | |
13 .. _segfault-plugin: | |
14 | |
15 Generating a segmentation fault for test purpose | |
16 ------------------------------------------------ | |
17 | |
18 .. highlight:: cpp | |
19 | |
20 Here is the source code of a minimal C++ :ref:`plugin | |
21 <creating-plugins>` that can be used to simulate a segmentation fault | |
22 within Orthanc:: | |
23 | |
24 #include <orthanc/OrthancCPlugin.h> | |
25 | |
26 extern "C" | |
27 { | |
28 int32_t OrthancPluginInitialize(OrthancPluginContext* context) | |
29 { | |
30 // Let's trigger a segmentation fault by writing to NULL | |
31 intptr_t *p = NULL; | |
32 *p = 42; | |
33 return OrthancPluginErrorCode_Success; | |
34 } | |
35 | |
36 void OrthancPluginFinalize() | |
37 { | |
38 } | |
39 | |
40 const char* OrthancPluginGetName() | |
41 { | |
42 return "crash"; | |
43 } | |
44 | |
45 const char* OrthancPluginGetVersion() | |
46 { | |
47 return "0.0"; | |
48 } | |
49 } | |
50 | |
51 As soon as Orthanc will try and load this plugin, it will crash. This | |
52 gives you the opportunity to learn how to debug Orthanc on your very | |
53 specific platform. | |
54 | |
55 | |
56 Any system | |
57 ---------- | |
58 | |
59 First :ref:`compile Orthanc by yourself <compiling>`, in debug mode by | |
60 setting ``-DCMAKE_BUILD_TYPE=Debug`` when invoking CMake. | |
61 | |
62 Then, learn how to use the debugger that is best suited to your | |
63 platform (e.g. Microsoft Visual Studio, gdb or Xcode). | |
64 | |
65 | |
66 GNU/Linux system using gdb | |
67 -------------------------- | |
68 | |
69 .. highlight:: bash | |
70 | |
71 The Orthanc project provides precompiled debug binaries that can be | |
241
f277d18e8d71
link to debug plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
240
diff
changeset
|
72 run on almost any recent GNU/Linux system (generated thanks to the |
f277d18e8d71
link to debug plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
240
diff
changeset
|
73 `LSB - Linux Standard Base SDK |
f277d18e8d71
link to debug plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
240
diff
changeset
|
74 <https://en.wikipedia.org/wiki/Linux_Standard_Base>`__). This allows |
f277d18e8d71
link to debug plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
240
diff
changeset
|
75 to generate a backtrace (the famous "core dumped" message) that can be |
f277d18e8d71
link to debug plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
240
diff
changeset
|
76 analyzed by any developer of Orthanc. Assuming that the :ref:`plugin |
f277d18e8d71
link to debug plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
240
diff
changeset
|
77 above <segfault-plugin>` is available as the ``crash.cpp`` file, here |
f277d18e8d71
link to debug plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
240
diff
changeset
|
78 is a sample debug session:: |
239 | 79 |
240 | 80 $ wget http://lsb.orthanc-server.com/orthanc/debug/1.5.6/Orthanc |
239 | 81 $ chmod +x ./Orthanc |
82 $ gcc -fPIC -shared ./crash.cpp -I ~/orthanc/Plugins/Include -o crash.so | |
83 $ ulimit -c unlimited | |
84 $ echo '{ "Plugins" : ["crash.so"] }' > Configuration.json | |
85 $ rm -f core ; ./Orthanc Configuration.json | |
86 W0427 15:43:24.215783 main.cpp:1436] Orthanc version: 1.5.6 | |
87 W0427 15:43:24.215910 main.cpp:1279] Performance warning: Non-release build, runtime debug assertions are turned on | |
88 W0427 15:43:24.217585 OrthancConfiguration.cpp:61] Reading the configuration from: "Configuration.json" | |
89 W0427 15:43:24.254733 main.cpp:700] Loading plugin(s) from: crash.so | |
90 W0427 15:43:24.254866 PluginsManager.cpp:269] Registering plugin 'crash' (version 0.0) | |
91 Segmentation fault (core dumped) | |
92 | |
93 | |
94 .. highlight:: text | |
95 | |
96 This session creates a file called ``core`` in the current working | |
97 directory. You can analyze it by running ``gdb`` as follows:: | |
98 | |
99 $ gdb -c ./core ./Orthanc | |
100 (gdb) bt | |
101 #0 0x00007f7b1aa3d739 in OrthancPluginInitialize () from crash.so | |
102 #1 0x00000000008632f0 in Orthanc::CallInitialize (plugin=..., context=...) | |
103 at /home/jodogne/BuildBotWorker/Orthanc_1_5_6_-_LSB_Debug/build/Plugins/Engine/PluginsManager.cpp:98 | |
104 #2 0x0000000000864496 in Orthanc::PluginsManager::RegisterPlugin (this=0x4314f90, path="crash.so") | |
105 at /home/jodogne/BuildBotWorker/Orthanc_1_5_6_-_LSB_Debug/build/Plugins/Engine/PluginsManager.cpp:272 | |
106 ... | |
107 | |
108 If you are unable to analyze such a backtrace by yourself, feel free | |
109 to post your ``core`` file on the `Orthanc forum | |
110 <https://groups.google.com/forum/#!forum/orthanc-users>`__. | |
111 | |
112 **Important:** The Orthanc developers will only be able to analyze the | |
113 ``core`` files generated by our own precompiled binaries! | |
114 | |
241
f277d18e8d71
link to debug plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
240
diff
changeset
|
115 **Plugins:** Besides the Orthanc core, debug binaries of the official |
f277d18e8d71
link to debug plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
240
diff
changeset
|
116 plugins precompiled using the LSB are also available at the following |
f277d18e8d71
link to debug plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
240
diff
changeset
|
117 locations: |
239 | 118 |
241
f277d18e8d71
link to debug plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
240
diff
changeset
|
119 * `Orthanc core <http://lsb.orthanc-server.com/orthanc/debug/>`__ |
f277d18e8d71
link to debug plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
240
diff
changeset
|
120 * `DICOMweb plugin <http://lsb.orthanc-server.com/plugin-dicom-web/debug/>`__ |
f277d18e8d71
link to debug plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
240
diff
changeset
|
121 * `MySQL plugin <http://lsb.orthanc-server.com/plugin-mysql/debug/>`__ |
f277d18e8d71
link to debug plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
240
diff
changeset
|
122 * `Orthanc Web viewer <http://lsb.orthanc-server.com/plugin-webviewer/debug/>`__ |
f277d18e8d71
link to debug plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
240
diff
changeset
|
123 * `PostgreSQL plugin <http://lsb.orthanc-server.com/plugin-postgresql/debug/>`__ |
f277d18e8d71
link to debug plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
240
diff
changeset
|
124 * `Transfers accelerator plugin <http://lsb.orthanc-server.com/plugin-transfers/debug/>`__ |
f277d18e8d71
link to debug plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
240
diff
changeset
|
125 * `Whole-slide imaging <http://lsb.orthanc-server.com/whole-slide-imaging/debug/>`__ |
f277d18e8d71
link to debug plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
240
diff
changeset
|
126 |
239 | 127 |
128 Docker | |
129 ------ | |
130 | |
131 To be written. |