-
Notifications
You must be signed in to change notification settings - Fork 101
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 corruption and possible memory leak due to ListLoggedInUsers() #36
Comments
i think i have the same issue,
im simply calling the did you have any luck @yusufozturk with fixing this? |
@si458 Yes I did. I will share it here. What I did, solved the memory corruption but memory leak is still happening. I fixed that by using WMI query to check logged users as a cache and if there is a change, then I use this method to bring user information. A bit dirty but works :) |
@yusufozturk brilliant! looking forward to request/share! |
@si458 sorry for the delay. here is the code. |
@yusufozturk code looks go, thanks! |
Aah sorry, wait, it was the wrong branch :) I'm sending the latest code, just made for our needs. We fill the state already so we can use it somewhere else. Also even the old code was keep crashing the program, so we tried to remove many parts that we don't need. If you need to use caching just like us, I would suggest following wmi query:
We check if there is any change via WMI, and if there is a change then we get the logged on list. I hope this would help you too. I would say this one works very long already. There are no memory corruption anymore but there is still some memory leak, so we fixed that by using caching. |
@si458 for wmi, we use a custom package of stackexchange/wmi. I believe this function makes the memory leak:
but we weren't able to fix it, so we added caching. |
If you think it's related to the LSA_UNICODE_STRING stuff, that memory is allocated by the Windows kernel (via whatever C function it is running inside the DLL to return the results)... Perhaps this call is failing?
Which should be telling Windows it can free the memory (as since it allocated it, it needs to do manual memory management to free it, C style). Allocated: Freed: As for the memory corruption, we've got quite a large deployment checking every 30 seconds with this call and have never seen it in our bug reporting, but perhaps we aren't checking frequently enough or something. I was under the impression Go was copying the strings to it's own memory locations when we convert them to native types, but perhaps I'm wrong and underneath it is still referencing the kernel allocated memory regions? It would make sense them that if the I have noticed an inconsistency between the two calls to |
Just putting in my useless comment. My users also experience this crash with an app that calls
|
Due to misuse of unsafe pointers, after a while go process crashes due to memory corruption.
Here is the output when memory corruption happens:
fatal error: unexpected signal during runtime execution
[signal 0xc0000005 code=0x1 addr=0xc0008cb910 pc=0xa4e77a]
After solving the issue, I will try to send a pull request.
The text was updated successfully, but these errors were encountered: