Software Development Kit (SDK) and API Discussions

Valgrind reports possible memory leaks in na_startup.

sistemasgmv

Hi all, I'm developing a little application in C using API version 5.1 and I use valgrind to detect memory leaks in my code. I have found a possible leak within the na_startup API call, just with the following code:

#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <locale.h>

#include <netapp_api.h>

int main(void)

{

    char *StartupErrBuf;

    StartupErrBuf=(char *)calloc(256,sizeof(char));

    na_startup(StartupErrBuf,strlen(StartupErrBuf));

    free(StartupErrBuf);

    na_shutdown();

    exit(1);

}

valgrind reports 41 allocs and only 21 frees. I'm not an expert developer but I guess there are some intermediate allocs which are not freed or maybe I'm doing something wrong.

This is part of the report from valgrind when it is used to analyze the compiled binary from the above code:

==31653== HEAP SUMMARY:

==31653==     in use at exit: 268 bytes in 20 blocks

==31653==   total heap usage: 40 allocs, 20 frees, 1,106 bytes allocated

==31653==

==31653== 3 bytes in 1 blocks are still reachable in loss record 1 of 20

==31653==    at 0x4A0610C: malloc (vg_replace_malloc.c:195)

==31653==    by 0x4FDFCD2: pool_alloc (pool.c:266)

==31653==    by 0x4FEC1F7: str_cat (str.c:798)

==31653==    by 0x4FDEF21: path_initialize_dirs (path.c:203)

==31653==    by 0x4FDEDFF: path_init (path.c:154)

==31653==    by 0x4C17E15: na_startup (na.c:270)

==31653==    by 0x40072C: main (startup.c:12)

==31653==

==31653== 7 bytes in 1 blocks are still reachable in loss record 2 of 20

==31653==    at 0x4A0610C: malloc (vg_replace_malloc.c:195)

==31653==    by 0x4FDFCD2: pool_alloc (pool.c:266)

==31653==    by 0x4FEC1F7: str_cat (str.c:798)

==31653==    by 0x4FDEF42: path_initialize_dirs (path.c:204)

==31653==    by 0x4FDEDFF: path_init (path.c:154)

==31653==    by 0x4C17E15: na_startup (na.c:270)

==31653==    by 0x40072C: main (startup.c:12)

Any help will be very appreciated.

Regards,

Eduardo

2 REPLIES 2

sens

Hi Eduardo,

We will look into the issue.

If it is indeed a memory leak, we will see if we can fix it in the upcoming releases of NMSDK.

Regards,

Sen.

sistemasgmv

Hi Sen, thank you for your answer. I have several valgrind logs regarding this issue and I can send them to you if you need them. I have made several tests with NMSDK 5.1 and 5.2 versions with the same results.

Regards,

Eduardo

Announcements
Register for Insight 2021 Digital

INSIGHT 2021 Digital: Meet the Specialists 2

On October 20-22, gear up for a fully digital, totally immersive virtual experience with a downright legendary lineup of world-renowned specialists. Tune in for visionary conversations, solution deep dives, technical sessions and more.

NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.

NetApp Insights to Action
I2A Banner
Public