The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Which Base Level Filesets needed by a specific program? cypher82 UNIX for Advanced & Expert Users 4 05-29-2008 08:07 AM
Help needed regarding c program dwgi32 High Level Programming 2 11-19-2007 10:44 AM
Wierd thing about FSs and VGs mhenryj AIX 4 11-13-2007 04:42 PM
Wierd results with awk amatheny Shell Programming and Scripting 2 11-01-2007 06:12 PM
Wierd Message???? lesstjm UNIX for Dummies Questions & Answers 6 01-04-2002 10:01 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #15 (permalink)  
Old 11-15-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
Typically stacks are extended by segment violations, rather than allocating a huge stack to a process, it puts guard pages below it and when you trip over those it grows the stack.
  #16 (permalink)  
Old 11-16-2007
karthikb23 karthikb23 is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 18
Thanks a lot guys! seems much more clear now
  #17 (permalink)  
Old 11-16-2007
DreamWarrior DreamWarrior is offline
Registered User
  
 

Join Date: Oct 2003
Posts: 70
Quote:
Originally Posted by karthikb23 View Post
could be, but when i printed out contents of j, it was "" (obviously, as it is a dummy).
But maybe there could be some garbage in the 15 bytes allocated.
Like u mentioned, it should dump core both times.

Also, like porter mentioned it is up to the OS when/how much it should be strict.
You would say "obviously" but then "obviously" all the other pointers should be set to NULL as well. Write to NULL should cause SEGV.... However, if it is "" then that is part of why the existence of 'j' is stopping you from SEGV. Because while sprintf is traversing the string 'i' to dump its contents into 'k', it immediately hits the NULL terminator and limits the damage done. Quite possibly the "damage" done lies entirely within the allocated stack and never SEGVs. Either way, you're clobbering stuff you shouldn't.

Furthermore, I'm not sure that a SEGV (by definition) is ALWAYS due to writes. There is a text and data segment and I would suspect that an attempt to read the text segment could also cause a SEGV in some operating systems.
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 05:16 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0