Not yet, Following the first answer in the forum I tried several code modifications around mprotect: 1. When releasing the memory, in addition to setting mprotect to PROT_READ and PROT_WRITE, set it PROT_EXEC 2. When allocating the memory, in addition to calling mprotect for the upper and lower parts of the allocated stack with PROT_NONE, Call mprotect with PROT_WRITE and PROT_READ for the valid part of the stack.
Each one of the above solutions solved the problem. (Separately) Regarding the small reproducer: The problem only appears after the tests bring the process up and down several times, And only after the pages where the problem appears were allocated for some other stack, released, and then allocated again for the current stack. I'm not sure how to reproduce this behavior in a small executable, I'll try now. Thank you for your reply, Masha. -----Original Message----- From: Philippe Waroquiers [mailto:philippe.waroqui...@skynet.be] Sent: Wednesday, June 12, 2013 10:44 PM To: Masha Naret (mnaret) Cc: valgrind-users@lists.sourceforge.net Subject: Re: [Valgrind-users] Valgrind shows "Invalid write os size 4" for memory allocated for the stack On Mon, 2013-06-10 at 01:23 -0700, mnaret wrote: > Hello, > Recently I'm getting lot's of "invalid read/invalid write" valgrind > errors which point out at memory allocated for the stack. However the > code doesn't crush and finish running successfully. > I'm trying to understand where the error comes from - and will be > grateful fo any help wih this issue. Do you have a small (compilable) reproducer ? Philippe ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev _______________________________________________ Valgrind-users mailing list Valgrind-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/valgrind-users