annotate Sphinx/source/faq/crash.rst @ 572:b78e8bf4d021

opensuse
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 26 Dec 2020 10:59:40 +0100
parents 090cc988c35e
children eaa6cdfa7ba6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
239
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 .. _crash:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 Crash analysis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 ==============
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5
244
26b0d7ece4af debugging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 241
diff changeset
6 Orthanc crashes very rarely. You are most likely looking for the FAQ
26b0d7ece4af debugging
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 241
diff changeset
7 entry about :ref:`debugging Orthanc <debugging>`.
239
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 .. _segfault-plugin:
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 Generating a segmentation fault for test purpose
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 ------------------------------------------------
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 .. highlight:: cpp
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 Here is the source code of a minimal C++ :ref:`plugin
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 <creating-plugins>` that can be used to simulate a segmentation fault
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 within Orthanc::
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 #include <orthanc/OrthancCPlugin.h>
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 extern "C"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 int32_t OrthancPluginInitialize(OrthancPluginContext* context)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 // Let's trigger a segmentation fault by writing to NULL
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 intptr_t *p = NULL;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 *p = 42;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 return OrthancPluginErrorCode_Success;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 void OrthancPluginFinalize()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 const char* OrthancPluginGetName()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 return "crash";
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 const char* OrthancPluginGetVersion()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 return "0.0";
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 As soon as Orthanc will try and load this plugin, it will crash. This
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 gives you the opportunity to learn how to debug Orthanc on your very
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 specific platform.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 GNU/Linux system using gdb
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 --------------------------
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 .. highlight:: bash
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 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
59 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
60 `LSB - Linux Standard Base SDK
f277d18e8d71 link to debug plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 240
diff changeset
61 <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
62 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
63 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
64 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
65 is a sample debug session::
239
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
568
090cc988c35e Orthanc 1.8.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 554
diff changeset
67 $ wget https://lsb.orthanc-server.com/orthanc/debug/1.8.2/Orthanc
239
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 $ chmod +x ./Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 $ gcc -fPIC -shared ./crash.cpp -I ~/orthanc/Plugins/Include -o crash.so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 $ ulimit -c unlimited
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 $ echo '{ "Plugins" : ["crash.so"] }' > Configuration.json
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 $ rm -f core ; ./Orthanc Configuration.json
568
090cc988c35e Orthanc 1.8.2
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 554
diff changeset
73 W0427 15:43:24.215783 main.cpp:1436] Orthanc version: 1.8.2
239
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 W0427 15:43:24.215910 main.cpp:1279] Performance warning: Non-release build, runtime debug assertions are turned on
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 W0427 15:43:24.217585 OrthancConfiguration.cpp:61] Reading the configuration from: "Configuration.json"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 W0427 15:43:24.254733 main.cpp:700] Loading plugin(s) from: crash.so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 W0427 15:43:24.254866 PluginsManager.cpp:269] Registering plugin 'crash' (version 0.0)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 Segmentation fault (core dumped)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 .. highlight:: text
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 This session creates a file called ``core`` in the current working
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 directory. You can analyze it by running ``gdb`` as follows::
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 $ gdb -c ./core ./Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 (gdb) bt
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 #0 0x00007f7b1aa3d739 in OrthancPluginInitialize () from crash.so
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 #1 0x00000000008632f0 in Orthanc::CallInitialize (plugin=..., context=...)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 at /home/jodogne/BuildBotWorker/Orthanc_1_5_6_-_LSB_Debug/build/Plugins/Engine/PluginsManager.cpp:98
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 #2 0x0000000000864496 in Orthanc::PluginsManager::RegisterPlugin (this=0x4314f90, path="crash.so")
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 at /home/jodogne/BuildBotWorker/Orthanc_1_5_6_-_LSB_Debug/build/Plugins/Engine/PluginsManager.cpp:272
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 ...
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 If you are unable to analyze such a backtrace by yourself, feel free
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 to post your ``core`` file on the `Orthanc forum
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 <https://groups.google.com/forum/#!forum/orthanc-users>`__.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 **Important:** The Orthanc developers will only be able to analyze the
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 ``core`` files generated by our own precompiled binaries!
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 Docker
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104 ------
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 To be written.