Re: purify: Free memory read. in shutdown_memory_manager

From: Date: Thu, 01 Jan 1970 00:00:00 +0000
Subject: Re: purify: Free memory read. in shutdown_memory_manager
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-3859@lists.php.net to get a copy of this message
> but when i purify i get the attached errors (and i don't understand > enough about the memory manager)... > > could please somebody of the bright guys have a look (and point me into > the "right" direction)???? > > the problem has to do with the statement struct that gets ecalloced in > oci8.c line 606 I guess you are talking about this block: **** Purify instrumented ./php (pid 28511) **** FUM: Freeing unallocated memory: * This is occurring while in: free [rtlib.o] shutdown_memory_manager [alloc.c:357] php3_request_shutdown [main.c:888] main [main.c:1859] _start [crt1.o] * Attempting to free block at 0x2d8db8 already freed. * This block was allocated from: malloc [rtlib.o] _emalloc [alloc.c:129] _ecalloc [alloc.c:201] oci8_parse [oci8.c:606] php3_oci8_parse [oci8.c:1533] cs_functioncall_post_variable_passing [control_structures_inline.h:930] * There have been 1 frees since this block was freed from: free [rtlib.o] shutdown_memory_manager [alloc.c:357] php3_request_shutdown [main.c:888] main [main.c:1859] _start [crt1.o] What is this saying? That shutdown_memory_manager() has been called twice and tried to free it both times? Or is it just telling us that shutdown_memory_manager() was the function to free it the second time? If the latter, I guess it can't tell us who freed the block the first time? If that is the case I might suspect that one of those OCI8 functions are trying to do a realloc() on it which would be bad news. If it does a realloc() and hands you back a new chunk of memory that is not under our control I would expect something along those lines. You wouldn't be able to use the PHP memory manager in that case and would have to do a straight malloc() and make very sure that you free the block yourself when you are done with it. The PHP memory manager is very simple. It just allocates a chunk of memory and then hands it out in smaller chunks when requested and maintains a linked list of these allocated blocks. If someone forgets to efree() a particular block, then on request shutdown it walks through the linked list and writes a little note in the error log informing us that someone didn't efree something and then it frees the entire chunk. It is an effective safety net which guards against memory leaks. -Rasmus -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#3859) next »