2

I'm trying to use gdb (Ubuntu 12.1) on my Ubuntu VM (22.04.1 LTS), but whenever I try the run command it always gives a segmentation fault, regardless of the program being debugged.

(gdb) run
Starting program: /home/dir/a.out

Program received signal SIGSEGV, Segmentation fault.
0x0000aaaa9aa5ac89 in ?? ()

This happens even with -g GCC option.

What's interesting is that on my laptop, with the same Ubuntu VM installed and same gcc/gdb versions, gdb works just fine. So I really don't understand what causes the problem.

I uninstalled and reinstalled both gcc and gdb, and even successfully ran a sudo apt update and consequent sudo apt upgrade, but that segmentation fault's still there.

EDIT: haven't found similar problems on the Internet, but I think that the cause of my problem could be VirtualBox (7.0.4), on which runs Ubuntu, that apparently is not completely supported by MacOS Ventura yet.

LeoPipo
  • 21
  • 2

2 Answers2

0

You could try downgrading to VirtualBox 6.1. I faced similar issues with VirtualBox 7.0.6 on MacOS Monterey, but then the problem was sorted after I downgraded to VirtualBox 6.1.42.

If that does not work, then the issue might be with Ventura.

0

The "0x0000aaaa9aa5ac89" is a suspicious address, which might lead to the root cause of this SEGV. I encountered a similar SEGV in gdb while loading the program's shared libraries in dl_main (glibc, pre main()), and I'm documenting it here in case it helps someone.

In my case, dl_main was causing SEGV. The setup was gdb debugging a remote program running under gdbserver. The host gdb was controlled by vscode with the setting "stopAtConnect: true".

I was able to resolve my SEGV by installing the same version of glibc on both the gdb host and the debug target running gdbserver.

I believe what was happening is that the stopAtConnect setting was inserting a breakpoint into the target process, but using the host debug symbol information, which was from a different version of glibc. I think the inserted breakpoint bytes altered some machine instruction in the target process such that it was doing something invalid.

Jaredo Mills
  • 159
  • 1
  • 8