-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SIGSEGV when run a program in gdb #278
Comments
Why do you breakpoint on 0x0? It's not a valid memory address.
If you'd like to breakpoint at the entry point, see: How to stop debugger right after the execution? |
It seems that breakpoint at the entry point does not work.
|
Maybe that is because of _dl_get_ready_to_run() in uClibc ? |
How does gdb implement break points? v86 ignores the trap flag, so execution continues normally, but I'm not sure if that's the problem here. The single byte trap instruction (INT3) is implemented in v86. Debug registers are not implemented. I suspect gdb uses debug registers. Could you check if that's the case? If it is, maybe we can convince it to use a different mechanism by clearing certain bits in cpuid or faulting when these registers are accessed. Afaik, I implemented read/write support for these registers because Haiku uses them as extra data registers. |
Well. I'll check it. |
@copy Is there a build environment and options for this image? If not, could you please provide one? I want to build and test gdb with the same environment and options as yours. This may make it easier to find what caused SIGSEGV in gdb. I'm using browser-vm but it seems that there are many differences with your image which will cause |
@hackeris It's a relatively old buildroot image. I don't have the config file for it any more. I'm pretty sure buildroot still supports old kernels, so you could modify the browser-vm image to your needs. I don't think this particular msr makes a difference though. |
There is another simulator(jslinux) which declares single stepping is not support. And I did not see any SIGSEGV while breaking or continuing my program with gdb in it. Maybe the problem in v86 is not about trap flag but debug registers? |
I'v ran program And when I debug my program written in assembly and compiled with yasm, what strange is that it will trigger SIGSEGV at instruction
The problem of SIGSEGV in gdb was marked as bug days ago. Is there any detail more about this bug? Or any strange case? |
I've also met this problem for musl libc gdb version 10.2, even with no breakpoints enabled. (image built just now with https://github.com/wokwi/browser-vm-gdb , simply switch libc to musl) compile this code in alpine linux g++ #include<iostream>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
cout<<a+b<<endl;
return 0;
} Meanwhile, I've noticed that gdb running on wokwi.com is functioning normally (see description at https://github.com/wokwi/web-gdb ), and breakpoints just work fine. So I don't think its a problem related to breakpoints. and then I tried to debug I haven't confirmed if it is a problem of some specific gdb version or problem with browser-vm builder itself. I'll build some other images later. |
When i trying to find which syscall crashed, I found a really interesting thing: It... runs successfully...
and also the same for uclibc:
I can't understand. |
I guess it's because of the |
That's a remote debugger for Arduino, so it doesn't matter if breakpoints are implemented in v86, the breakpoints are executed on the Arduino.
You can change this flag: https://github.com/copy/v86/blob/master/src/rust/config.rs#L2 |
Ok I've confirmed that is not a problem related to jit. |
|
I want to debug my program with gdb on v86. But after just loaded my program to gdb and started, I got "Program received signal SIGSEGV, Segmentation fault".
And I tried to toggle breakpoint, the program could be paused and continue at first few breakpoints, but I still got "Program received signal SIGSEGV, Segmentation fault" if I continue later.
The program I loaded can be run correctly without gdb. Is there any unimplemented feature or bug in vm? Or any option missing while building image?
I'm working on debugging v86 in my browser to find it, but it seems not easy. Glad to contribute if it is caused by something unimplemented or bug.
Steps here:
I use yasm for demonstration.
The first instruction in _start is a call to _dl_start, so I toggle breakpoints at first two instructions of _dl_start.
The program can be paused at breakpoint 2 (_dl_start + 0) like this.
And there is a break point at (_dl_start + 1), it is expected to be paused at breakpoint 3 (_dl_start + 1) if I continue again.
It says SIGSEGV like this.
Image here:
https://pan.baidu.com/s/1Udjtb9_SAkIIW9zg09jHsw
Password: heuf
The text was updated successfully, but these errors were encountered: