断点改变程序流程

断点改变程序流程

本文介绍了断点改变程序流程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我试图分析和反转一个Objective-C程序。

我通过手动更改某些操作码对可执行文件进行了少量修改。然而,当我测试修改过的软件时,我得到了

没关系,我想我碰到了一些我不应该做的事情。为了分析错误,我启动了 gdb myprogram 。这里发生了一些事情(对我来说很奇怪):如果我没有放置任何断点,程序会收到SIGKILL,而如果我试图在收到信号之前几行放置一个断点,似乎没有任何事情发生,程序似乎可以正常工作很好。



从这里我的问题是:断点是否改变程序流程?

如果答案是否定的,那么我想我写的信息不足以解决问题,所以请问,如果您有一些提示或建议将我指向正确的方向,我将不胜感激。



我使用MacOS 10.7.4和 gdb 6.3.50(Apple版本gdb-1752)。假设我无法访问源代码。

解决方案

改变代码工作方式的断点的头号原因是种族条件。它基本上是这样的:

 没有断点:$ b​​ $ b发出一些异步请求
做一些响应
错误,因为请求尚未响应

带有断点:$ b​​ $ b发送一些异步请求
等待用户继续
响应等待继续时到达
做出回应
的事情OK!


I'm trying to analyze and reverse a Objective-C program I have.

I made few modifications to the executable by changing some opcodes by hand. When I test the modified software, however, I get

That's fine, I think I touched something I should not. I launched then gdb myprogram in order to analyze the error. Here something (strange to me) happened: if I do not put any breakpoint the program receives SIGKILL, while if I try to put a breakpoint few lines before the one in which I receive the signal nothing seems to happen and the program seems to work fine.

From here my question: does a breakpoint change the program flow?
If the answer is no, then I imagine the informations I wrote are not enough to solve so please ask, I would appreciate if you have some tips or suggestions to point me to the right direction.

I'm using MacOS 10.7.4 and gdb 6.3.50 (Apple version gdb-1752). Assume I don't have access to the source code.

解决方案

The number one cause for breakpoints altering how the code works is race conditions. It basically goes like this:

Without breakpoints:
    make some asynchronous request
    do something with response
    ERROR because request hasn't responded yet

With breakpoints:
    send some asynchronous request
    wait for user to continue
    response arrived while waiting for the continue
    do something with response
    OK!

这篇关于断点改变程序流程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 13:43