LinuxQuestions.org
Help answer threads with 0 replies.
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 09-16-2009, 09:43 AM   #1
theosib
LQ Newbie
 
Registered: Sep 2009
Posts: 2

Rep: Reputation: 0
Please help: Program freezes in printf (__write_nocancel)


I'm not sure where to begin with describing this problem, but here's my situation. I'm using gnuscreen, but I can't tell if this has anything to do with my problem. (The text is actually going over the network through ssh to another box.)

I've written a program that produces a LOT of text output to stdout. Like a megabyte/sec. Sometimes, the program will just freeze. If I press ctrl-z and then type "fg", it continues where it left off.

I connected a debugger. Here's the stack trace:

(gdb) where
#0 0x00007f342e1a72e0 in __write_nocancel () from /lib/libc.so.6
#1 0x00007f342e1520ea in _IO_new_file_write (f=0x7f342e437780, data=0x7f342edfd083, n=187) at fileops.c:1268
#2 0x00007f342e151d4a in new_do_write (fp=0x7f342e437780,
data=0x7f342edfd000 "\033[7m25\033[m 4 5 \033[7m 6 \033[m\033[7m 6 \033[m 1 5 5 4 5 \033[7m 6 \033[m 5 5 5 5 5 5 5 3 \033[7m 6 \033[m 5 3 5 \033[7m 6 \033[m\033[7m 6 \033[m\033[7m 6 \033[m 4 5 5 5 5 4 4 \033[7m 6 \033[m 5 \033[7m 6 \033[m 171\n 172\n 171"..., to_do=187) at fileops.c:522
#3 0x00007f342e152085 in _IO_new_do_write (fp=0x1,
data=0x7f342edfd083 "\033[m 4 5 5 5 5 4 4 \033[7m 6 \033[m 5 \033[7m 6 \033[m 171\n 172\n 171\n 171\n4 4 3 171\n 173\nm22\033[m \033[7m23\033[m \033[7m24\033[m \033[7m25\033[m \033[7m26\033[m \033[7m27\033[m \033[7m28\033[m \033[7m29\033[m \033[7m30\033[m \033[7m31\033[m \033[7m3"..., to_do=187) at fileops.c:494
#4 0x00007f342e151ea9 in _IO_new_file_xsputn (f=0x7f342e437780, data=0x40420b, n=1) at fileops.c:1350
#5 0x00007f342e125359 in _IO_vfprintf_internal (s=0x7f342e437780, format=<value optimized out>, ap=0x7fffb255b2b0) at vfprintf.c:1610
#6 0x00007f342e1c7e9d in ___printf_chk (flag=1, format=0x0) at printf_chk.c:37
#7 0x0000000000401274 in common_table ()
#8 0x0000000000402be8 in fixup_all_overlaps ()
#9 0x0000000000402d5e in main ()

So basically, it's getting stuck in something called by printf.

Does anyone have any ideas as to how to investigate why this freeze might be happening?

Thanks.
 
Old 09-17-2009, 11:16 AM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
If screen is left in 'copy' mode, it's buffer will fill and writes to stdout will block. Is this possibly the problem?

--- rod.
 
Old 09-18-2009, 08:54 AM   #3
theosib
LQ Newbie
 
Registered: Sep 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by theNbomr View Post
If screen is left in 'copy' mode, it's buffer will fill and writes to stdout will block. Is this possibly the problem?

--- rod.
Good though, but no. I was watching the program work (which involves a lot of text updating on the screen), when suddenly, it froze. I could switch screens (in screen), but only suspending and restarting the program would unfreeze it.
 
Old 09-19-2009, 08:16 PM   #4
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,229

Rep: Reputation: 173Reputation: 173
maybe you are writing two fast
try slowing it down just to test
i am new to linux so i dont completely know what anybody is talking about
but in dos if you write to fast i have had the computer freeze
 
Old 09-22-2009, 06:26 PM   #5
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
Is it possible to not use screen, at least for the purposes of diagnosing the problem? Is screen open in multi-user mode? If so, how many displays are active? Is it possible to eliminate the network from the equation? Sustained MB/sec throughput is pretty high, especially if multiple users are watching. Your stack trace shows what appear to be many, many embedded escape sequences, all of which require interpretation by screen, and the accordant terminal manipulation. As much as I was prepared to dismiss smeezekitty's reply as specious, I wonder whether there may be some validity to it.
--- rod.
 
Old 09-23-2009, 01:40 AM   #6
smeezekitty
Senior Member
 
Registered: Sep 2009
Location: Washington U.S.
Distribution: M$ Windows / Debian / Ubuntu / DSL / many others
Posts: 2,229

Rep: Reputation: 173Reputation: 173
try writing to the screen as fast as possable on a 386
be ready to press CTL+ALT+DEL
 
  


Reply

Tags
freeze, io, programming


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Help with printf command in C program snowman81 Programming 8 04-08-2008 12:12 AM
`screen` program freezes sethb Linux - Server 3 09-23-2006 08:41 PM
How could a program crash between 2 printf() 's? paul76 Programming 12 09-11-2003 12:17 PM
Opengl program freezes RH 9.0 ssd_123 Linux - Software 1 06-03-2003 01:55 PM
OpenGL program freezes RH 9.0 ssd_123 Programming 2 06-03-2003 01:49 PM


All times are GMT -5. The time now is 08:45 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration