Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Leak in CoreV1API #96

Closed
minerba opened this issue Dec 13, 2021 · 8 comments
Closed

Memory Leak in CoreV1API #96

minerba opened this issue Dec 13, 2021 · 8 comments
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@minerba
Copy link

minerba commented Dec 13, 2021

Hi

I found some defect that Memory Leak in CoreV1API.c

In the "CoreV1API_deleteNamespacedPod" function, the localVarToReplace variable calls malloc, but if the __namespace variable is NULL, it moves to end and the function ends without calling free.
Other functions are also confirmed to have memory leak.

It needs to be fixed as soon as possible.

@ityuhui
Copy link
Member

ityuhui commented Dec 13, 2021

Could you please provide a sample (yaml) or gdb call stack ?

The example delete_pod has passed valgrind test. No memory leak is reported.

@minerba
Copy link
Author

minerba commented Dec 13, 2021

Hi @ityuhui

In normal cases, memory leak does not occur, but if (__namespace == NULL)
Memory leak occurs.

  char* localVarToReplace_name = malloc(sizeOfPathParams_name);
    sprintf(localVarToReplace_name, "{%s}", "name");

    localVarPath = strReplace(localVarPath, localVarToReplace_name, name);

    // Path Params
    long sizeOfPathParams_namespace = strlen(name)+3 + strlen(_namespace)+3 + strlen("{ namespace }");
    if(_namespace == NULL) {
        goto end;
    }

============= end ==============

end:
    free(localVarPath);
    return NULL;

@ityuhui
Copy link
Member

ityuhui commented Dec 13, 2021

Thank you @minerba I got it.

It's a problem. But I think its severity is low because only if _namespace == NULL, it will reproduce. So I will fix this some times later.


The fix solution is:

  1. define all pathParams at the begining and initialize their value to "NULL"
  2. free all non-NULL pathParams at the end code block.
    https://github.com/OpenAPITools/openapi-generator/blob/fbb61658dfbcc2c1f5087511b0f74756553791ad/modules/openapi-generator/src/main/resources/C-libcurl/api-body.mustache#L116

@minerba
Copy link
Author

minerba commented Dec 13, 2021

@ityuhui thanks for your reply. I hope it will be fixed soon

@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle stale
  • Mark this issue or PR as rotten with /lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 13, 2022
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Close this issue or PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Apr 12, 2022
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue or PR with /reopen
  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

@k8s-ci-robot
Copy link
Contributor

@k8s-triage-robot: Closing this issue.

In response to this:

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues and PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Reopen this issue or PR with /reopen
  • Mark this issue or PR as fresh with /remove-lifecycle rotten
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

No branches or pull requests

4 participants