天道酬勤,学无止境

strace

Strace With C Executable?

I had multiple simple questions in my latest job interview. At first, I was asked to write a simple program that takes an input x from the user and allocates (using malloc) x bytes in memory. I simply wrote: void main() { int x; scanf("%d",&x); malloc(x); } Then I was told to show all the system calls being called when running my executable so I went to the terminal and types: strace ./my_program.o Which was great until he asked something like: The output you received from running strace on your program was probably very messy. And there’s no way to tell which system call was used during the

2022-05-02 02:01:20    分类:问答    c   linux   malloc   system-calls   strace

Hung processes resume if attached to strace

I have a network program written in C using TCP sockets. Sometimes the client program hangs forever expecting input from server. Specifically, the client hangs on select() call set on an fd intended to read characters sent by server. I am using strace to know where the process got stuck. However, sometimes when I attach the hung client process to strace, it immediately resumes it's execution and properly exits. Not all hung processes exhibit this behavior, some processes stuck in the select() even if I attach them to strace. But most of the processes resume their execution when attached to

2022-04-17 02:31:45    分类:问答    sockets   linux-kernel   gdb   strace   ptrace

Using strace fixes hung memory issue

I have a multithreaded process running on RHEL6.x (64bit). I find that the process hangs and some threads (of the same process) crash most of the time when I try to bring up the process. Some threads wait for shared memory between the threads to get created (I can see that all of it does not get created). But when I use strace , the process does not hang and it works just fine (all of the memory that is supposed to be created, gets created). Even interrupting strace after the memory gets created, keeps the process running fine for good. I have read this: strace fixes hung process which did

2022-04-05 06:16:30    分类:问答    unix   process   kernel   rhel   strace

strace java小程序(strace java applet)

问题

2022-04-05 05:42:15    分类:技术分享    java   strace   nanotime

How do you debug a LONG RUNNING php script?

The problem is that the script hangs up after some long time. strace returns something like this and nothing else: Process 7286 attached - interrupt to quit restart_syscall(<... resuming interrupted call ...>) = 0 poll([{fd=13, events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}], 1, 0) = 0 (Timeout) clock_gettime(CLOCK_MONOTONIC, {1817569, 74651533}) = 0 clock_gettime(CLOCK_MONOTONIC, {1817569, 74734744}) = 0 clock_gettime(CLOCK_MONOTONIC, {1817569, 74812047}) = 0 poll([{fd=13, events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}], 1, 1000) = 0 (Timeout) poll([{fd=13, events=POLLIN|POLLPRI|POLLRDNORM

2022-04-04 07:10:25    分类:问答    php   xdebug   strace   postmortem-debugging

strace java applet

I'm trying to strace a java applet, and strace doesn't seem to be working. I'm calling the following function. public static void testSTrace(){ long c = 0; for (int i = 0; i < 1000; i++){ long start = System.nanoTime(); try{Thread.sleep(0, 100);}catch(Exception e){/*cry*/} long stop = System.nanoTime(); log.info("start : " +start+" stop : "+stop); } } I get the following output from strace just before the above message is called and then nothing from strace: clone(child_stack=0xb7c9f4c4, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM| CLONE_SETTLS|CLONE_PARENT

2022-03-22 15:03:37    分类:问答    java   strace   nanotime