Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
libssh-mirror
libssh-mirror
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 73
    • Issues 73
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 9
    • Merge requests 9
  • Requirements
    • Requirements
    • List
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI/CD
    • Code Review
    • Insights
    • Issue
    • Repository
    • Value Stream
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • libssh project
  • libssh-mirrorlibssh-mirror
  • Issues
  • #57

Closed
Open
Created Mar 30, 2021 by Anderson Sasaki@ansasakiDeveloper

T238: "ssh_init" and "ssh_finalize" leaks memory

Description

Originally reported by matick: https://bugs.libssh.org/T238

Whenever ssh_init is called, function "ssh_mutex_lock" will allocate memory for mutex, but this memory is never released. I would expect that mutex "ssh_init_mutex" is released upon "ssh_finalize", but it is not. image

image

Comments:

Jakuje commented on 2020-08-12 11:37:26 UTC:

This looks like Windows-only issue. If the pthreads on Linux are used, the mutex is initialized statically, which is probably a reason why it does not pop up for us. It looks like windows locks do not support static initialization.

At this moment, there s no simple way to free this particlar mutex, but given that it is really one-off allocation when libssh is initialized, one-off leak during finalization and this memory is not growing throughout the usage it is very low priority to solve now.


matick commented on 2020-08-12 11:54:15 UTC:

I guess that if in function "static int _ssh_finalize(unsigned destructor)" this: if (!destructor) { ssh_mutex_unlock(&ssh_init_mutex); } return 0; would be replaced with this: if (!destructor) { ssh_mutex_unlock(&ssh_init_mutex); if (!_ssh_initialized) { free(ssh_init_mutex); ssh_init_mutex = SSH_MUTEX_STATIC_INIT; } } return 0;

It should work just fine without leaks.


Jakuje commented on 2020-08-12 13:45:17 UTC:

On windows yes, but it would fail everywhere else, where ssh_init_mutex is static mutex. Feel free to submit your suggested change in the gitlab -- it should run it through the CI to check if it works:

https://gitlab.com/libssh/libssh-mirror


To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking