Article View: aus.computers.linux
Article #56116Re: Memory Allocation Problems
From: Dan
Date: Wed, 09 Apr 1997 00:00
Date: Wed, 09 Apr 1997 00:00
45 lines
2252 bytes
2252 bytes
Jason Nunn (jsno@stormfront.com.au) wrote: : Dan (dbentley@metz.une.edu.au) wrote: : it allocate a block of memory and get a segmentation fault, it would have : to be a pretty big!. : Thats what I looked at. I placed a pause just before where I was getting the error, and found that it was nowhere near the largest memory allocations on my beast (Which is something like 8Mb for one program). So I tried using electric fence... : what compiler switches are you using? : I have tried changing many of the switches, and even tried without switches (Optimization may have caused a problem I thought, but it was not). : also, if you isolate just the memory allocations, do you still get the : same problem? : I isolated the memory alocations, and the error did not occure. So it had to be the memory allocations. : ....that's the only thing i can suggest really without looking at the : complete program. : As I have said, I have found the solution (thanks for your help guys). I have not exactly solved the problem yet, as the line is just commented out. There were two problems: 1) I was using sizeof instead of strlen for a string - very stupid mistake. 2) This is the one I can not fix (Electric fence found this one at a higher level than where the code was crashing): I am using strcpy to copy a string. The destination string has been allocated the right ammount of memory, but when it copies, I get the segmentation fault. I do have another way round the problem if I can not figure out why it is crashing. Thanks for any help. And now I must go and thank whoever made electric fence (I must also read through the stuff on its usage and copyright - whoops)... Dan.
Technical Details
Message-ID:
<5if39k$69k$1@gruvel.une.edu.au>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<5iareb$i91$1@gruvel.une.edu.au> <33492BEA.830839C@eris.dev.null> <5ibtd0$13m$1@gruvel.une.edu.au> <334b85d5.0@news.topend.com.au>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 102983,b7f2caa39b1617c0 X-Google-Attributes: gid102983,public From: dbentley@metz.une.edu.au (Dan) Subject: Re: Memory Allocation Problems Date: 1997/04/09 Message-ID: <5if39k$69k$1@gruvel.une.edu.au> X-Deja-AN: 231835876 References: <5iareb$i91$1@gruvel.une.edu.au> <33492BEA.830839C@eris.dev.null> <5ibtd0$13m$1@gruvel.une.edu.au> <334b85d5.0@news.topend.com.au> Organization: University of New England, NSW, Australia Newsgroups: aus.computers.linux