Breakpoint changes program flow

吃可爱长大的小学妹 提交于 2019-12-10 17:59:48

问题


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

Killed: 9

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.


回答1:


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!


来源:https://stackoverflow.com/questions/12083526/breakpoint-changes-program-flow

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!