LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-07-2013, 03:39 AM   #1
fantasy1215
Member
 
Registered: Oct 2011
Posts: 75

Rep: Reputation: Disabled
program crashed with EPIPE while without core dump


I use strace to watch a running program, and catch the information when the program crashed. Now I paste the strace information as follow:
Code:
9134  select(8, NULL, [7], NULL, {2, 0}) = 1 (out [7], left {2, 0})
9134  write(7, "V\0                              "..., 88) = -1 EPIPE (Broken pipe)
9134  --- SIGPIPE (Broken pipe) @ 0 (0) ---
8858  <... msgrcv resumed> 98307, {1749233712, ": 33 30 30 31 30 30 34 31 33 35 "...}, 2048, 0, 0) = ? ERESTARTNOHAND (To be restarted)
8859  <... futex resumed> )             = -1 EINTR (Interrupted system call)
8858  +++ killed by SIGPIPE +++
8859  +++ killed by SIGPIPE +++
10080 <... futex resumed> )             = -1 EINTR (Interrupted system call)
8856  <... select resumed> )            = ? ERESTARTNOHAND (To be restarted)
10080 +++ killed by SIGPIPE +++
8856  +++ killed by SIGPIPE +++
I have questions:
1. Why would the EPIPE occur?
2. How could I fix this problem?
3. Why wouldn't it generate a coredump?(I've set ulimit -c unlimited already)

Edit: After I googled broken pipe, I add signal(SIGPIPE, SIG_IGN); to my program, But my program still crashed by EPIPE (Broken pipe). This is a socket server program.

And the thread I googled is http://www.unix.com/programming/1633...ogramming.html

Last edited by fantasy1215; 06-07-2013 at 07:12 PM.
 
Old 06-07-2013, 04:01 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,913

Rep: Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318
sigpipe or broken pipe means the communication channel (the pipe itself) has been destroyed. Usually it caused because the other side (the app) died, therefore no app can handle the communication.
So usually either stdin or stdout is redirected to/from another app, but there can be other situation as well.
It will not cause core, it has no meaning in this case. You need to find the other end of the pipe and check that app.
 
Old 06-07-2013, 04:37 AM   #3
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,869
Blog Entries: 1

Rep: Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870
For non-trivial programs (meaning: that handle error conditions on write), add this:

Code:
signal (SIGPIPE, SIG_IGN);
 
Old 06-07-2013, 08:49 AM   #4
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Quote:
Originally Posted by NevemTeve View Post
For non-trivial programs (meaning: that handle error conditions on write), add this:

Code:
signal (SIGPIPE, SIG_IGN);
Additionally, this makes EPIPE a possible errno value for a failed write operation, which might need to be considered separately from the other possible errors.
Quote:
Originally Posted by fantasy1215 View Post
3. Why wouldn't it generate a coredump?(I've set ulimit -c unlimited already)
If you look at man 7 signal, it says that SIGPIPE results in termination rather than a core dump, presumably since there isn't a real need to perform a backtrace.

Kevin Barry

Last edited by ta0kira; 06-07-2013 at 08:52 AM.
 
Old 06-07-2013, 07:14 PM   #5
fantasy1215
Member
 
Registered: Oct 2011
Posts: 75

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by NevemTeve View Post
For non-trivial programs (meaning: that handle error conditions on write), add this:

Code:
signal (SIGPIPE, SIG_IGN);
Now I've added signal (SIGPIPE, SIG_IGN); already to my program, but the program still gets crashed by EPIPE.
 
Old 06-07-2013, 10:19 PM   #6
ta0kira
Senior Member
 
Registered: Sep 2004
Distribution: FreeBSD 9.1, Kubuntu 12.10
Posts: 3,078

Rep: Reputation: Disabled
Quote:
Originally Posted by fantasy1215 View Post
Now I've added signal (SIGPIPE, SIG_IGN); already to my program, but the program still gets crashed by EPIPE.
That's a problem with how you handle EPIPE, then. If you want the program to continue, close the descriptor that had the EPIPE and set a flag that indicates that output should be skipped.

Kevin Barry
 
Old 06-08-2013, 04:31 AM   #7
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,869
Blog Entries: 1

Rep: Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870Reputation: 1870
> Now I've added signal (SIGPIPE, SIG_IGN); already to my program, but the program still gets crashed by EPIPE.

1. What does strace show?
2. And gdb?

3. Your program seems to be multi-thread (or multi-proces?), try using 'signal' right before the write.

Last edited by NevemTeve; 06-08-2013 at 04:33 AM.
 
Old 06-08-2013, 05:09 AM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,913

Rep: Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318Reputation: 7318
Why don't you try to catch the other side? You saw write(7, "V\0 "..., 88) = -1 EPIPE (Broken pipe), so you need to check how it (file descriptor = 7) was opened and why it was dropped (died ??)
 
Old 06-08-2013, 05:27 AM   #9
fantasy1215
Member
 
Registered: Oct 2011
Posts: 75

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by NevemTeve View Post
> Now I've added signal (SIGPIPE, SIG_IGN); already to my program, but the program still gets crashed by EPIPE.

1. What does strace show?
2. And gdb?

3. Your program seems to be multi-thread (or multi-proces?), try using 'signal' right before the write.
Thanks for your reply, and the strace message showed still as the same as before.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Program crash without core dump? fantasy1215 Programming 3 05-27-2013 01:39 PM
analyzing C program core dump using GDB (Cannot access memory) m4rtin Programming 3 08-31-2010 03:27 PM
Does core dump analysis require program arguments? hs_linux Programming 2 07-23-2010 02:46 AM
[SOLVED] Why core dump analysis require a program name? hs_linux Programming 3 07-22-2010 12:55 AM
Core dump issues. Program crashes but does not generate core dump file sabeel_ansari Programming 1 10-07-2009 04:23 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration