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

Fix CFileTree::GetNodeFullPath memory leak #53

Merged
merged 2 commits into from
Nov 13, 2017

Conversation

Toilal
Copy link
Contributor

@Toilal Toilal commented Oct 2, 2017

It also use const char* instead of char* for immutable strings

It also use const char* instead of char* for immutable strings
src/FileTree.cpp Outdated
}
}

char* CFileTree::GetNodeFullPath(tree_node_<FILE_ITEM>* node)
std::string CFileTree::GetNodeFullPath(tree_node_<FILE_ITEM>* node)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The effective fix is here (returning std::string instead of char*).

@Toilal
Copy link
Contributor Author

Toilal commented Oct 3, 2017

After more that one day running this fork, #52 didn't occur. The process actually eats up far less memory than it did (actually 52 016K for Private Bytes, and 2 776K for Working Set).

@Toilal
Copy link
Contributor Author

Toilal commented Oct 3, 2017

Here's the compiled EXE for people who wants to test this fork. It includes #53 and #51.

WinNFSd.zip

@marcharding
Copy link
Member

Hey, looks good. #34 had the same approach but i had problems after i applied the patch.

(I realized this week that this was probably due to the introduced canonical path functions in the #34 patch above, GetFullPathName/GetFullPathNameW would solve that)

I'll testrun your fixes the next few days 👍

@Toilal
Copy link
Contributor Author

Toilal commented Oct 3, 2017

Sadly it doesn't seem to fix #29 as I hit this exact issue this morning, but it really seems to fix #52 and reduce memory usage drastically.

@Toilal
Copy link
Contributor Author

Toilal commented Oct 12, 2017

I still need to work on this.

In some case, getPathByHandle can return NULL, but it cause a crash because method has to return std::string. I'll add an exception instead of returning NULL, and catch it to return a proper error to NFS client.

@Toilal
Copy link
Contributor Author

Toilal commented Oct 12, 2017

@marcharding, I just add a new commit bcf1689 that fixes crashes when an invalid handle (unknown tree item) is requested by the client. It should fix #54.

It has occured on my environment in a reproductible manner, so I could debug and fix this issue properly. It also pass std::string by reference. That's the first time I write C++, so I was a bit confused at first with those changes, but I think I now understand the keys of memory management.

I attach the binary from HEAD of this branch for people who wants to test.

WinNFSd.zip

@marcharding
Copy link
Member

Looks good so far, i'll test it a few more days to see if there are any regressions. 👍 👍 👍

@kriks57
Copy link

kriks57 commented Nov 13, 2017

I've been using it for some days now and it's stable for me. The memory consumption stopped to increase and is stabilized around 50MB.
thanks!

@Toilal
Copy link
Contributor Author

Toilal commented Nov 13, 2017

We have been running this on a team of 5 developers since one month, and no more crash too, at least when using UDP protocol.

I think it could be merged and released @marcharding please :)

@marcharding
Copy link
Member

Will do later today 👍

@marcharding marcharding merged commit b75b2ed into winnfsd:master Nov 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants