View previous topic :: View next topic |
Author |
Message |
meyerm Veteran
Joined: 27 Jun 2002 Posts: 1311 Location: Munich / Germany
|
Posted: Sat Jul 27, 2002 4:32 pm Post subject: gdb doesn't work without root-priviledges |
|
|
Howdy,
when I try to debug a buggy program in gdb, I always get this error:
Code: | meyerm@pegasus buffer $ gdb buggy
GNU gdb 5.1.1
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
(gdb) run 123
Starting program: /home/meyerm/c/buffer/buggy 123
Cannot exec : No such file or directory.
Program exited with code 0177.
You can't do that without a process to debug.
(gdb) |
That's real strange. Doing the same on SuSE works. There was a thread some time ago which stated, this is a permissions problem. And right, when I start gdb as root, it works.
But that can't be. I don't want to get root everytime I debug. I looked after suid but neither in gentoo nor in SuSE it is set. What else could it be? Any clues?
Thanks,
Marcel
BTW: Just to assure there are no "external execs" in my program, here it is (hey, it is just to test smashing the stack ):
Code: | void catargs (int argc, char** argv) {
char buffer[32];
char *b = buffer;
int i;
for (i=1; i<argc; i++) {
strcpy(b, argv[i]);
b += strlen(argv[i]);
if(i+1 != argc) *b++ = ';';
}
printf("Alle zusammen: %s\n", buffer);
}
int main (int argc, char** argv) {
catargs(argc, argv);
return 0;
}
|
|
|
Back to top |
|
|
sa Guru
Joined: 10 Jun 2002 Posts: 450
|
Posted: Sat Jul 27, 2002 11:36 pm Post subject: |
|
|
hmm it works here:
Quote: | sa@f ~ % gdb buggy
GNU gdb 5.1.1
Copyright 2002 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...
(gdb) run 123
Starting program: /home/sa/buggy 123
Alle zusammen: 123
Program exited normally.
|
may I suggest running "strace -o buggy_gdb.out gdb ./buggy"
then examining buggy_gdb.out for any clues. |
|
Back to top |
|
|
meyerm Veteran
Joined: 27 Jun 2002 Posts: 1311 Location: Munich / Germany
|
Posted: Sun Jul 28, 2002 12:06 am Post subject: |
|
|
sa wrote: | may I suggest running "strace -o buggy_gdb.out gdb ./buggy" then examining buggy_gdb.out for any clues. |
Sure!
OK, the relevant part for me seems to be
Code: | getrusage(RUSAGE_SELF, {ru_utime={0, 0}, ru_stime={0, 0}, ...}) = 0
stat64("/home/meyerm/c/buffer/./buggy", {st_mode=S_IFREG|0755, st_size=14604, ...}) = 0
write(1, "Starting program: /home/meyerm/c"..., 52) = 52
vfork() = 8083
--- SIGCHLD (Child exited) ---
sigreturn() = ? (mask now [RTMIN])
wait4(-1, [WIFEXITED(s) && WEXITSTATUS(s) == 127], 0, NULL) = 8083
fcntl64(0, F_GETFL) = 0x2 (flags O_RDWR)
brk(0x828d000) = 0x828d000
ioctl(0, SNDCTL_TMR_TIMEBASE, {B38400 opost isig icanon echo ...}) = 0
ioctl(0, 0x540f, [8081]) = 0
write(1, "\n", 1) = 1
write(1, "Program exited with code 0177.\n", 31) = 31
fstat64(3, {st_mode=S_IFREG|0755, st_size=14604, ...}) = 0
stat64("/home/meyerm/c/buffer/./buggy", {st_mode=S_IFREG|0755, st_size=14604, ...}) = 0
write(2, "You can\'t do that without a proc"..., 45) = 45
write(2, "\n", 1) = 1
|
I don't know id this is true. I'm a real beginner in "such things".
The whole output can be found for at least a few days at the web for download.
Thank you for your answer and for any possible following. |
|
Back to top |
|
|
sa Guru
Joined: 10 Jun 2002 Posts: 450
|
Posted: Sun Jul 28, 2002 2:31 am Post subject: |
|
|
ok it looks like your problem is happening with whatever vfork() runs.
try the following to make strace follow the vfork(),
"strace -v -F -ff -o foo gdb buggy"
this should create two files foo and foo.* try looking at foo.* and mabey compare it to strace ran as root. _hopefully_ this will tell you what is (or isnt) happening.
sa
P.S. make sure your editor does syntax highlighting before reading that strace output, you dont want your eyes to go googly. |
|
Back to top |
|
|
sa Guru
Joined: 10 Jun 2002 Posts: 450
|
Posted: Sun Jul 28, 2002 3:07 am Post subject: |
|
|
ok, I think I know what is wrong. I just tried running gdb after 'export SHELL=""' and I got the same error as you! try running `export SHELL=/bin/bash` and then running gdb, I think you can run chsh to fix it also.
hth,
sa |
|
Back to top |
|
|
meyerm Veteran
Joined: 27 Jun 2002 Posts: 1311 Location: Munich / Germany
|
Posted: Sun Jul 28, 2002 10:52 am Post subject: |
|
|
WOW! Great! It works. I'm truly impressed.
Thank you very, very much!
How did you discover this? I would have never tried changing a SHELL-variable. |
|
Back to top |
|
|
sa Guru
Joined: 10 Jun 2002 Posts: 450
|
Posted: Mon Jul 29, 2002 2:21 am Post subject: |
|
|
When I installed gentoo I didnt have a $SHELL var either. I just remembered that when I realized gdb vforks a shell to execute its test subject. In other words it was a Lucky guess
sa |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|