Hello,

I am quite new to libuv, so please pardon my newbie question.

I am seeing a memory leak when i do uv_spawn for which the options.file 
doesn't exist. I do know if we use 
uv_strerror http://docs.libuv.org/en/v1.x/errors.html#c.uv_strerror it will 
leak for unknown error codes, but this is a known error code (even with 
uv_strerror commented out i still see the same leak). 

More Context: I am writing a light weight remote execution program 
(daemon), since i am getting small memory leak my code is core dumping if i 
hit it hard with concurrent requests (if i comment out the test case which 
caused uv_spawn to fail, then i am all good). 

I am using *libuv-1.8.0*

*Code*

tmp ~$ cat spawn.c

#include <stdio.h>

#include <inttypes.h>


#include <uv.h>


uv_loop_t *loop;

uv_process_t child_req;

uv_process_options_t options;


void on_exit(uv_process_t *req, int64_t exit_status, int term_signal) {

    fprintf(stderr, "Process exited with status %" PRId64 ", signal %d\n", 
exit_status, term_signal);

    uv_close((uv_handle_t*) req, NULL);

}


int main() {

    loop = uv_default_loop();


    char* args[3];

    args[0] = "/bin/no_mkdir"; *// no such command*

    args[1] = "test-dir";

    args[2] = NULL;


    options.exit_cb = on_exit;

    options.file = "/bin/no_mkdir"; *//** no such command*

    options.args = args;


    int r;

    if ((r = uv_spawn(loop, &child_req, &options))) {

        fprintf(stderr, "%s\n", uv_strerror(r));

        return 1;

    } else {

        fprintf(stderr, "Launched process with ID %d\n", child_req.pid);

    }


    return uv_run(loop, UV_RUN_DEFAULT);

}

tmp ~$ 


*Compile*

tmp ~$ gcc -g -o spawn spawn.c -luv


*valgrind*

...snip...==12179== HEAP SUMMARY:

==12179==     in use at exit: 152 bytes in 2 blocks

==12179==   total heap usage: 2 allocs, 0 frees, 152 bytes allocated

==12179== 

==12179== 24 bytes in 1 blocks are definitely lost in loss record 1 of 2

==12179==    at 0x4A06A2E: malloc (vg_replace_malloc.c:270)

==12179==    by 0x4C286EB: uv_spawn (process.c:418)

==12179==    by 0x400858: main (spawn.c:28)

==12179== 

==12179== 128 bytes in 1 blocks are still reachable in loss record 2 of 2

==12179==    at 0x4A06A2E: malloc (vg_replace_malloc.c:270)

==12179==    by 0x4A06BA2: realloc (vg_replace_malloc.c:662)

==12179==    by 0x4C2233A: uv__io_start (core.c:779)

==12179==    by 0x4C29260: uv_signal_init (signal.c:225)

==12179==    by 0x4C2786E: uv_loop_init (loop.c:66)

==12179==    by 0x4C2020D: uv_default_loop (uv-common.c:567)

==12179==    by 0x4007FF: main (spawn.c:16)

==12179== 

==12179== LEAK SUMMARY:

==12179==    definitely lost: 24 bytes in 1 blocks

==12179==    indirectly lost: 0 bytes in 0 blocks

==12179==      possibly lost: 0 bytes in 0 blocks

==12179==    still reachable: 128 bytes in 1 blocks

==12179==         suppressed: 0 bytes in 0 blocks

==12179== 

==12179== For counts of detected and suppressed errors, rerun with: -v

==12179== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 6 from 6)

no such file or directory

==12178== 

..snip..

*i am not worried about uv_run leak because i am not closing it correctly 
(or is it a problem?).*

-- 
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 https://groups.google.com/group/libuv.
For more options, visit https://groups.google.com/d/optout.

Reply via email to