• <bdo id='tZffH'></bdo><ul id='tZffH'></ul>
    <tfoot id='tZffH'></tfoot>

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

  • <legend id='tZffH'><style id='tZffH'><dir id='tZffH'><q id='tZffH'></q></dir></style></legend>

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

        使用“尝试";避免分段错误

        时间:2023-08-06
          <bdo id='qC3I6'></bdo><ul id='qC3I6'></ul>
          1. <small id='qC3I6'></small><noframes id='qC3I6'>

          2. <legend id='qC3I6'><style id='qC3I6'><dir id='qC3I6'><q id='qC3I6'></q></dir></style></legend>

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

                    <tbody id='qC3I6'></tbody>

                  本文介绍了使用“尝试";避免分段错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  最近在我的一个程序中,我遇到了分段错误问题.我设法找到了导致问题的线路,但我还没有找到解决方法.

                  Recently in one of my programs I got a segmentation fault problem. I managed to find the line that its is causing the problem but I haven't find the way of fixing it.

                  行:

                  self.window_player.add(self.vlc)
                  

                  其中 self.vlc 是一个小部件,self.window_player 是一个空的 Gtk.Window() 在 glade 中创建.

                  where self.vlc is a widget and self.window_player is an empty Gtk.Window() created in glade.

                  该行在我的程序的 __init__ 处,所以实际上这个问题只在启动程序时发生.奇怪的事实是,错误只出现了 10 次中的 1 次(启动程序)

                  The line is at the __init__ of my program, so actually this problem only happen when launching the program. The weird fact is that the error only appears like 1 of 10 times (of launching the program)

                  错误:Segmentation fault 是我从终端得到的唯一输出

                  the error: Segmentation fault is the only output that I get from the terminal

                  所以我尝试了:

                  while True:
                      try:
                          self.window_player.add(self.vlc)
                          break
                      except:
                          print "segmentation"
                  

                  问题是try似乎没有排除分段错误!

                  The problem is that the segmentation fault don't seems to be excepted by the try!

                  推荐答案

                  对不起,你处理不了.段错误是由内存损坏、超出自有内存边界的读取或写入、双重释放和其他一些原因引起的.

                  Sorry, you can't handle it. A segfault is caused by memory corruption, reading or writing beyond boundaries of owned memory, double frees, and a few other.

                  您可以在此处找到一些导致段错误的问题示例:

                  You can found a few examples of issues that cause a segfault here:

                  https://gist.github.com/carlos-jenkins/8873932

                  操作系统会杀死有问题的程序,你无能为力.您唯一的解决方案是纠正根本问题.

                  The operating system will kill the offending program, you can't do much about it. Your only solution is to correct the root problem.

                  您可以使用 Valgrind 工具运行程序,它可以让您准确找到问题所在:

                  You can run a program using the tool Valgrind, it will allow you to find exactly where the problem is:

                  http://valgrind.org/

                  在 Ubuntu 上,只需 sudo apt-get install valgrind 然后 valgrind <program cmd> 将启动程序.这种偏离会慢很多,但大多数时候会发现问题.

                  On Ubuntu, just sudo apt-get install valgrind and then valgrind <program cmd> will launch the program. This offcourse will be a lot slower, but will identify the problem most of the time.

                  旁注:从技术上讲,您可以通过为该信号注册回调来捕获 SIGSEV 信号.但你不应该.有关更多信息,请参阅此答案:

                  Side note: Technically you can catch a SIGSEV signal by registering a callback for this signal. But you shouldn't. See this answer for more information:

                  https://stackoverflow.com/a/10203062/439494

                  这篇关于使用“尝试";避免分段错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:捕获“分段错误"崩溃子进程的消息:调用com 下一篇:Python - C 嵌入式分段错误

                  相关文章

                  最新文章

                  • <bdo id='Y9QJf'></bdo><ul id='Y9QJf'></ul>

                  1. <tfoot id='Y9QJf'></tfoot>

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

                    1. <legend id='Y9QJf'><style id='Y9QJf'><dir id='Y9QJf'><q id='Y9QJf'></q></dir></style></legend>

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