lopilo24
lopilo24

Reputation: 21

Gdb task suspended (tty output)

When attempting to run a binary (in the background) in gdb after hitting a breakpoint I get the following message :

[1] + 4636 suspended (tty output) gdb exploit_me

The problem seems to happen whatever i'm running gdb in bash, zsh or as root it appears that it happens only when i had set a breakpoint.

➜ Buffer_Overlow_1 gdb --version

GNU gdb (Debian 8.3-1) 8.3
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

➜ Buffer_Overlow_1 stty -a

speed 38400 baud; rows 24; columns 80; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl -ixon -ixoff
-iuclc -ixany -imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke -flusho -extpro

c

Here is the program "exploit_me"

➜ Buffer_Overlow_1 cat exploit_me.c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void func(char *arg)
{
    char buffer[64];
    strcpy(buffer,arg);
    printf("%s\n", buffer);
}

int main(int argc, char *argv[])
{
    if(argc != 2) printf("binary \n");
    else func(argv[1]);
    return 0;
}

Upvotes: 1

Views: 2757

Answers (1)

Employed Russian
Employed Russian

Reputation: 213385

Your forgot to ask a question. You also didn't show your complete session (how you are actually interacting with GDB, how you are setting a breakpoint, etc.).

Presumably, your question is "why does this happen and what can I do to prevent it from happening".

The suspended (tty output) means that the background task attempted to read input from the terminal, and was stopped with SIGTTYOUT. Read more about it here.

If this was allowed, your foreground shell and background task would race to read whatever you are typing, with each getting ~50% of the typed characters. This is almost never what you want.

As to what can you do to prevent this: don't run GDB in the background, unless you are running it with --bath flag and supplying all the commands it needs via a script.

Upvotes: 3

Related Questions