• <small id='KO2kO'></small><noframes id='KO2kO'>

      <i id='KO2kO'><tr id='KO2kO'><dt id='KO2kO'><q id='KO2kO'><span id='KO2kO'><b id='KO2kO'><form id='KO2kO'><ins id='KO2kO'></ins><ul id='KO2kO'></ul><sub id='KO2kO'></sub></form><legend id='KO2kO'></legend><bdo id='KO2kO'><pre id='KO2kO'><center id='KO2kO'></center></pre></bdo></b><th id='KO2kO'></th></span></q></dt></tr></i><div id='KO2kO'><tfoot id='KO2kO'></tfoot><dl id='KO2kO'><fieldset id='KO2kO'></fieldset></dl></div>

        • <bdo id='KO2kO'></bdo><ul id='KO2kO'></ul>
        <legend id='KO2kO'><style id='KO2kO'><dir id='KO2kO'><q id='KO2kO'></q></dir></style></legend>
      1. <tfoot id='KO2kO'></tfoot>

      2. 什么可能导致 dynamic_cast 崩溃?

        时间:2023-09-26
      3. <small id='MZCbG'></small><noframes id='MZCbG'>

        <i id='MZCbG'><tr id='MZCbG'><dt id='MZCbG'><q id='MZCbG'><span id='MZCbG'><b id='MZCbG'><form id='MZCbG'><ins id='MZCbG'></ins><ul id='MZCbG'></ul><sub id='MZCbG'></sub></form><legend id='MZCbG'></legend><bdo id='MZCbG'><pre id='MZCbG'><center id='MZCbG'></center></pre></bdo></b><th id='MZCbG'></th></span></q></dt></tr></i><div id='MZCbG'><tfoot id='MZCbG'></tfoot><dl id='MZCbG'><fieldset id='MZCbG'></fieldset></dl></div>
        <legend id='MZCbG'><style id='MZCbG'><dir id='MZCbG'><q id='MZCbG'></q></dir></style></legend>
            <bdo id='MZCbG'></bdo><ul id='MZCbG'></ul>

                  <tbody id='MZCbG'></tbody>

                  <tfoot id='MZCbG'></tfoot>
                1. 本文介绍了什么可能导致 dynamic_cast 崩溃?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一段代码如下:

                  TAxis *axis = 0;
                  if (dynamic_cast<MonitorObjectH1C*>(obj))
                     axis = (dynamic_cast<MonitorObjectH1C*>(obj))->GetXaxis();
                  

                  有时会崩溃:

                  Thread 1 (Thread -1208658240 (LWP 11400)):
                  #0  0x0019e7a2 in _dl_sysinfo_int80 () from /lib/ld-linux.so.2
                  #1  0x048c67fb in __waitpid_nocancel () from /lib/tls/libc.so.6
                  #2  0x04870649 in do_system () from /lib/tls/libc.so.6
                  #3  0x048709c1 in system () from /lib/tls/libc.so.6
                  #4  0x001848bd in system () from /lib/tls/libpthread.so.0
                  #5  0x0117a5bb in TUnixSystem::Exec () from /opt/root/lib/libCore.so.5.21
                  #6  0x01180045 in TUnixSystem::StackTrace () from /opt/root/lib/libCore.so.5.21
                  #7  0x0117cc8a in TUnixSystem::DispatchSignals ()
                     from /opt/root/lib/libCore.so.5.21
                  #8  0x0117cd18 in SigHandler () from /opt/root/lib/libCore.so.5.21
                  #9  0x0117bf5d in sighandler () from /opt/root/lib/libCore.so.5.21
                  #10 <signal handler called>
                  #11 0x0533ddf4 in __dynamic_cast () from /usr/lib/libstdc++.so.6
                  

                  我不知道它为什么会崩溃.obj 不为空(如果是这样就没有问题,是吗?).

                  I have no clue why it crashes. obj is not null (and if it was it would not be a problem, would it ?).

                  动态转换崩溃的原因可能是什么?

                  What could be the reason for a dynamic cast to crash ?

                  如果它不能强制转换,它应该只返回 NULL 否?

                  If it can't cast, it should just return NULL no ?

                  推荐答案

                  崩溃的一些可能原因:

                  • obj 指向具有非多态类型的对象(没有虚拟方法的类或结构,或基本类型).
                  • obj 指向一个已经被释放的对象.
                  • obj 指向未映射的内存,或已映射的内存以在访问时产生异常的方式(例如保护页或不可访问的页).
                  • obj 指向具有多态类型的对象,但该类型是在禁用 RTTI 的情况下编译的外部库中定义的.
                  • obj points to an object with a non-polymorphic type (a class or struct with no virtual methods, or a fundamental type).
                  • obj points to an object that has been freed.
                  • obj points to unmapped memory, or memory that has been mapped in such a way as to generate an exception when accessed (such as a guard page or inaccessible page).
                  • obj points to an object with a polymorphic type, but that type was defined in an external library that was compiled with RTTI disabled.

                  并非所有这些问题都会在所有情况下导致崩溃.

                  Not all of these problems necessarily cause a crash in all situations.

                  这篇关于什么可能导致 dynamic_cast 崩溃?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:理解 gsl::narrow 实现 下一篇:嵌入式 Lua - 超时流氓脚本(例如无限循环) - 任何人的例子?

                  相关文章

                  <small id='wAV2c'></small><noframes id='wAV2c'>

                    <tfoot id='wAV2c'></tfoot>

                        <bdo id='wAV2c'></bdo><ul id='wAV2c'></ul>
                    1. <legend id='wAV2c'><style id='wAV2c'><dir id='wAV2c'><q id='wAV2c'></q></dir></style></legend>

                      <i id='wAV2c'><tr id='wAV2c'><dt id='wAV2c'><q id='wAV2c'><span id='wAV2c'><b id='wAV2c'><form id='wAV2c'><ins id='wAV2c'></ins><ul id='wAV2c'></ul><sub id='wAV2c'></sub></form><legend id='wAV2c'></legend><bdo id='wAV2c'><pre id='wAV2c'><center id='wAV2c'></center></pre></bdo></b><th id='wAV2c'></th></span></q></dt></tr></i><div id='wAV2c'><tfoot id='wAV2c'></tfoot><dl id='wAV2c'><fieldset id='wAV2c'></fieldset></dl></div>