[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [CPROG] Realloc



On Tue, 27 Feb 2001, Martin wrote:

> 
> On 27 Feb, Mogens Kjaer wrote: 
>  Kan det være fordi du refererer til Ptr og ikke Ptr2 efter realloc?
> 
> Om jag skriver det lite tydligare: 
> 
> out("Before %s %d\n", Ptr, ll); 
> Ptr2 = (char *) realloc(Ptr, ll); 
> out("After\n"); 
> 
> if(Ptr2 == NULL){ 
>     error handling 
> } else { 
>     Ptr = Ptr2; 
> } 
> 
> out() är en funktion som är likvärdig till vfprintf/printf och den fungerar (== välbeprövad). 
> 
> Första out() raden kommer fram, och därför vet jag att Ptr och ll har rimliga värden. Men den andra out satsen "After" kommer inte fram. Det är därför som jag antar att det är på den raden som vi krashar på. 
> 
> Det är inte första gången jag utökar bufferten som vi krashar. Jag hara redan gjort det några gånger innan det sker. Därför tycker jag att det är väldigt märkligt. 

Har du kigget på noterne til realloc?

       Crashes in malloc(), free() or realloc() are almost always
       related to heap corruption, such as overflowing  an  allo­
       cated chunk or freeing the same pointer twice.

       Recent  versions of Linux libc (later than 5.4.23) and GNU
       libc (2.x) include a malloc implementation which  is  tun­
       able  via  environment  variables.   When MALLOC_CHECK_ is
       set, a special (less  efficient)  implementation  is  used
       which  is  designed  to be tolerant against simple errors,
       such as double calls of free() with the same argument,  or
       overruns of a single byte (off-by-one bugs).  Not all such
       errors can be proteced against, however, and memory  leaks
       can  result.   If  MALLOC_CHECK_ is set to 0, any detected
       heap corruption is silently ignored; if set to 1, a  diag­
       nostic  is  printed  on  stderr;  if  set to 2, abort() is
       called immediately.  This can be useful because  otherwise
       a  crash may happen much later, and the true cause for the
       problem is then very hard to track down.

bortset fra det - kan vi ikke se et dump af ovenstående? Hvilke størrelser
anvendes, m.v.

Mads

-- 
Mads Bondo Dydensborg.                               sslug@sslug
64 GB PAE mode works just fine on my 8GB RAM, 8-way Xeon box [..]
                      
                                 - Ingo Molnar, Linux Kernel List, 1999-11-03



 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:08 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *