-
Notifications
You must be signed in to change notification settings - Fork 78
CreateProcessW(): Invalid access to memory location #111
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
Comments
@adamedx @ksubrama @smurawski - Could one of our Windows gurus give this a look? Thanks, Peter |
@docwhat Could you give us the powershell block/command being used that trips this? I don't believe that the string being provided is read-only. It is composed dynamically by the powershell_script resource and I don't see any big changes to mixlib-shellout that would cause this to not work when it would have been working before. If it is the read-only argument issue, having a repro would be nice to help track it down. |
We have about 50 Windows VMs and we get about one error a day. So I don't have any reproducible string. Since I use the I think that it mainly happens in |
To further clarify. I also tried combinations of cookbooks in a vagrant and could never reproduce it either. No matter how I tried. If I was going to go further I'd try using Windows debugging tools in a Vagrant, but I'm not familiar with debugging at that level in Windows nor at that level with FFI. Is there a way I can do some kind of introspection inside the FFI code that I could run on one or more of the live systems? I can't recompile anything on them that They are all running 12.4.1. I could try 12.4.3 I guess. I don't recall which version of Chef was on them previously and I couldn't tell you for sure if it was an upgrade the Chef, cookbooks, or Windows itself that made this likely to happen. |
@docwhat The upstream library we use was apparently binding the second argument as an input only buffer. I'm unsure as the what the actual effect of that is - the FFI documentation claims that it is a hint that they can use for "optimizations". But it's a possible lead. |
The MSDN docs said it must be both input and output. I imagine the optimization include putting the variable in read only memory. Sounds like a significant lead! Pointers to the code for those of us playing along at home? |
https://github.com/djberg96/win32-process/blob/ffi/lib/win32/process/functions.rb#L59 . The github issue I referenced above also mentions other possible bugs in the code. |
Is there any solution for this issue? We have the same issue and could not find and solution. |
I'm getting these errors randomly (and hard to reproduce) on my boxen:
They don't happen at any particular recipe for any particular cookbook. That is, they are pretty random.
What I think is happening is that
CreateProcessW()
is passing in a "constant" version ofcmd
. According to the MSDN Documentation's forlpCommandLine
:The error message "Invalid access to memory location" is consistent with the second argument (
lpCommandLine
) being within read-only memory.I think the fix is to change
core_ext.rb
line 226 to use an allocated bit of memory:I'm not sure
1024
is the right value. Other examples I have seen use things like (reverting to C/C++) the following:or
If it helps, there is a Microsoft blog post about why
CreateProccesW()
has historically had this behavior: http://blogs.msdn.com/b/oldnewthing/archive/2009/06/01/9673254.aspxThe text was updated successfully, but these errors were encountered: