Hi Saghul,

No, this is not a small and lib uv only test case. But the error is caused 
only if we issue free() in uv_close or in uv_close_callback. Below is the 
code of writer :

char *resp_msg;
resp_msg = (char*) malloc( 400 );
bzero( resp_msg, sizeof(resp_msg) );
strcpy( resp_msg, response );
uv_buf_t buf = uv_buf_init( resp_msg, sizeof(resp_msg));//part 2
buf.len = strlen(resp_msg);
buf.base = resp_msg;

uv_write_t *writer = (uv_write_t *) malloc(sizeof(uv_write_t));
writer->data = (void*) buf.base;
uv_write(writer, (uv_stream_t*) _client, &buf, 1, on_client_write);


On Friday, December 20, 2013 2:08:43 PM UTC+5:30, Saúl Ibarra Corretgé 
wrote:
>
> On 12/20/2013 06:39 AM, Sarav Sandhu wrote: 
> > Hi Ben/libuv team, 
> > 
> > While analysing the memory allocation with valgrind memory analyser 
> > tool, I've observed the following error while calling free() in 
> > uv_close's callback : 
> > 
> > ==32732== 
> > ==32732== Invalid free() / delete / delete[] 
> > ==32732==    at 0x4004FDA: free (vg_replace_malloc.c:233) 
> > ==32732==    by 0x80521A3: uv__finish_close (core.c:204) 
> > ==32732==    by 0x80521DA: uv__run_closing_handles (core.c:218) 
> > ==32732==    by 0x8052457: uv_run (core.c:316) 
> > ==32732==    by 0x8050328: ppp (ppp.c:96) 
> > ==32732==    by 0x804AD79: main (main.c:108) 
> > ==32732==  Address 0x806B880 is not stack'd, malloc'd or (recently) 
> free'd 
> > ==32732== 
> > 
> > The code for the same is : 
> > 
> > void on_file_write(uv_write_t *req, int status) { 
> >          uv_close( (uv_handle_t*) req->handle, (uv_close_cb) free ); 
> >          free( req->data ); 
> > } 
> > 
> > uv_write(writer, (uv_stream_t*) &req_file, &buf, 1, on_file_write); 
>
> How are you allocating writer here? 
>
> Also, do you have a small and libuv-only test case exposing the issue? 
>
>
> Thanks, 
>
> -- 
> Sa�l Ibarra Corretg� 
> bettercallsaghul.com 
>

-- 
You received this message because you are subscribed to the Google Groups 
"libuv" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/libuv.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to