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