Application behaving in 3 different ways on 3 different machines


 
Thread Tools Search this Thread
Top Forums Programming Application behaving in 3 different ways on 3 different machines
# 8  
Old 01-07-2013
That is not what #3 is meant to say - that memory WAS part of a now extinct process - that is why you cannot konw the contents of memory beforehand.
# 9  
Old 01-07-2013
Memory that came from an extinct process gets blanked before anything else gets it.

What may be different is different arrangements of the stack frame, and the like. With the compiler options you have that days (stack protectors, etc) it can vary quite a bit.
This User Gave Thanks to Corona688 For This Post:
# 10  
Old 01-11-2013
I knew about undefined memory areas.
What is confusing me is when you do some implicit definitions like
Code:
char * mystring="some text";

So, as corona said, somehow my pointers should have already been initialized to some available memory area.
And this has consistently been the case on a single machine.
It consistently wasn't on another two machines.
# 11  
Old 01-11-2013
Quote:
Originally Posted by erupter
I knew about undefined memory areas.
What is confusing me is when you do some implicit definitions like
Code:
char * mystring="some text";

So, as corona said, somehow my pointers should have already been initialized to some available memory area.
And this has consistently been the case on a single machine.
It consistently wasn't on another two machines.
Um, no. I was telling you that what you were doing is wrong, not that what you were doing ought to work.

Let me put it this way.

"some text" becomes valid memory when compiled. That text has to get into the program somehow, right? (It's unwritable memory, fyi, so if you try and edit it you'll get a surprise.) It's not an implicit strcpy. The memory already exists and will exist for the entire duration of the program. You do not need to copy the string to have it.

The pointer itself, though? Until you make it point to anything valid, can point to valid or invalid memory, depending wholly on chance and undefined things.

So lets compare your two methods of assignment:

Code:
char *mysterymemory;
// mysterymemory points to god-knows-what when the program starts.
// Let's play memory roulette and write to god-knows-what!
// This might work, or might write 'mystring' right into the middle of my return frame,
// or even crash immediately.
strcpy(mysterymemory, "mystring");


Code:
// This pointer does not point to god-knows-what.
// This pointer points to the valid memory that "mystring" exists inside.
// The bytes "mystring" don't have to be written anywhere.
// This is not anything like strcpy.
// We are just pointing to memory that ALREADY EXISTS.
char *validmemory="mystring";


Last edited by Corona688; 01-11-2013 at 11:51 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

[Solved] wc behaving weirdly

Can anyone explain why wc is behaving weirdly? Their are only 2 occurrences but wc thinks their are 7 occurrences. I have even manually checked this. $ grep -i base * lit: base xx lit.lst:003- 00103 BASE XX $ grep -i base * | wc -w ... (2 Replies)
Discussion started by: cokedude
2 Replies

2. Shell Programming and Scripting

awk not behaving as expected

Hi, Immediate help on below will be appreciated. I have to read a file (max of 10MB) which will have no new line characters, i.e. data in single line. and have to inster '\n' at every 100 characters. and if record starts with 'BUCA' then need to pick value of length 10 at position 71 and... (7 Replies)
Discussion started by: maks475
7 Replies

3. UNIX and Linux Applications

Linux application upgrade ways

Hello. I need upgrade memcached. This software is installed throuth yum. In official repositories isn`t newest version of memcached, but this one is vulnerable. So looks like I need built it from source, but I dont really want to install c libraries un compilers on system. 1.) So can I compile... (0 Replies)
Discussion started by: jabalv
0 Replies

4. Red Hat

nslookup behaving strangely

I have two servers on same domain. one can nslookup other cannot Psu100 can lookup to psu000, psu010 & psu011 Psu110 can NOT lookup to psu000, psu010 & psu011 I verified resolv.conf entries on both psu000 and psu010 and it contains both name servers (10.200.10.21 & 10.200.11.22).I am... (1 Reply)
Discussion started by: scorohan
1 Replies

5. UNIX for Advanced & Expert Users

FTP behaving erraneous way

Hi Gurus, I tried FTP one file to UNIX which got values like wel^come If I see the content in unix, it shows like wel^Zcome ^ coverted into ^Z (Control + Z ) Can someone please share what is happening here? Thanks, Shahnaz (5 Replies)
Discussion started by: shahnazurs
5 Replies

6. Shell Programming and Scripting

tr command behaving unexpectedly

Im trying to execute the below command on our server to list files and replace the newline in the file list with spaces, but the character 'n' is getting replaced with a space, is there any environment variable that needs to be set in UNIX? sh -c 'ls -trx... (1 Reply)
Discussion started by: rameshrr3
1 Replies

7. Red Hat

application to be run on machines connected in same network

I have a set up of 5 machines which are connected in same network. Now i want to run a small application so that those machines are not ideal. (0 Replies)
Discussion started by: pradeepreddy
0 Replies

8. UNIX for Advanced & Expert Users

csplit not behaving

I have a large file with the first 2 characters of each line determining the type of record. type 03 being a subheader and then it will have multiple 04 records. eg: 03,xxx,xxxx,xxxx 04,xxxxxxxxxxxxxxxxxxxxxxxxxxxx 04,xxxxxxxxxxxxxxxxxxxxxxxxxxxx 03,xxx,xxx,xxx ... (2 Replies)
Discussion started by: badg3r
2 Replies

9. UNIX for Advanced & Expert Users

ftp application behaving erratically

Hi, I am working on a custom made FTP application. The application is behaving erratically for the "ls" command. Wild card character passed to the "ls" command (like "ls *temp") is giving inconsistent results. On debuggin I have found that the "ls" command is implemented as shown below in the... (7 Replies)
Discussion started by: diganta
7 Replies
Login or Register to Ask a Question