Bug 320036 (MONO77240) - memory for DynamicMethods should not be malloced
Summary: memory for DynamicMethods should not be malloced
Status: RESOLVED FIXED
: 403721 (view as bug list)
Alias: MONO77240
Product: Mono: Runtime
Classification: Mono
Component: JIT (show other bugs)
Version: 1.1
Hardware: Other Other
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Paolo Molaro
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-13 18:06 UTC by Paolo Molaro
Modified: 2008-06-25 15:24 UTC (History)
3 users (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 19:44:30 UTC


---- Reported by lupus@ximian.com 2006-01-13 11:06:47 MST ----

Currently we allocate the memory for the native code for DynamicMethods
with malloc and mprotect it to be executable.
This is the wrong thing to do, since it means we're mprotecting all over
the address space, even memory that is not used for the dynamic method,
since mprotect only works for page sized chunks. Also, when we'll free the
memory, the page will remain executable.
The Dynamic method code should use the usual method for allocating
executable memory in page-sized chunks (we could have a global
MonoCodeManager for dynamic methods) and allocate the needed memory from
that space. Obviuosly this requires a small malloc-like implementation.


Unknown operating system unknown. Setting to default OS "Other".

Comment 1 Forgotten User vxPDddArjq 2008-04-08 10:33:48 UTC
This also seems to cause problems under Windows with Data Execution Prevention
(DEP) on.
Comment 2 Aras Pranckevicius 2008-04-08 11:04:37 UTC
Expanding on DEP problem on Windows:

For dynamic methods, mono-codeman allocates memory using malloc (which does not set proper execute bits on Windows).

Additionally, a call to mono_mprotect is never made on Windows in that case (#ifdef'd out), so trying to execute that code with DEP on results in access violation. I can't tell from the log why #ifdef was added there (it just says "don't call mono_mprotect on windows", svn rev. 71629).
Comment 3 Forgotten User vxPDddArjq 2008-04-09 20:40:08 UTC
This should now be fixed in SVN. Could you try this patch on windows:

http://lists.ximian.com/pipermail/mono-patches/2008-April/115112.html

Comment 4 Aras Pranckevicius 2008-04-13 19:25:37 UTC
This patch makes it work under DEP correctly (only tested with Mono compiled with Visual Studio though).
Comment 5 Mike Kestner 2008-06-25 15:24:30 UTC
*** Bug 403721 has been marked as a duplicate of this bug. ***