Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: vm_protect with VM_PROT_COPY not working on Leopard



Jeremy,

Depending on how you define run-time, one can conditionally interpose at launch by use of the DYLD_INSERT_LIBRARIES environmental variable. "man dyld" for more information. "man libgmalloc" for precedence.

davez


On Mar 6, 2008, at 7:53 AM, Jeremy Todd wrote:

That's good news - the one remaining problem is that it would be nice if I could enable this at runtime. Is it true that interposing must be done by the linker at link-time?

I'm also still wondering why the vm_protect() VM_PROT_COPY mechanism described below is failing under Leopard. Surely it must be possible to get write access to the malloc() implementation somehow. For example doesn't gdb need this sort of access?

Regards,
Jeremy




-----Original Message-----
From: Eric Gouriou [mailto:email@hidden]
Sent: Thursday, March 06, 2008 1:06 AM
To: Jeremy Todd
Cc: Darwin Dev
Subject: Re: vm_protect with VM_PROT_COPY not working on Leopard


On Mar 5, 2008, at 9:07 PM, Jeremy Todd wrote:
This looks interesting, but I'm curious whether it will allow me to
replace all invocations of malloc. For example if my code calls a
function defined in some system library, and that function in turn
calls malloc(), will it call my interposed malloc?

Yes, even calls to malloc() from within libc / libsystem (e.g., strdup()).

malloc (and friends) is one of those entry points for which
interposing is part of the ABI contract. Direct calls to its
default implementation are not allowed, everything must go
through the dynamic symbol resolution.

 Such guarantees do not exist in general for other library
entry points.
Intra-library calls are frequently done directly, bypassing
the dyld logic.

  Eric

Jeremy


-----Original Message-----
From: Chris Sarcone [mailto:email@hidden]
Sent: Wednesday, March 05, 2008 6:03 PM
To: Jeremy Todd
Cc: email@hidden
Subject: Re: vm_protect with VM_PROT_COPY not working on Leopard

Jeremy --

You might find this helpful:

http://developer.apple.com/documentation/DeveloperTools/Concep
tual/DynamicLibraries/DynamicLibraries.pdf

Search for "interposing".


-- Chris

On Mar 5, 2008, at 2:44 PM, Jeremy Todd wrote:


Hi, I'm trying to patch the malloc function
[...]
	In case anyone is wondering, I need to do this as part of our
development process for audio plug-ins. These plug-ins should not
call certain functions (including malloc) from the high-priority
processing thread to avoid priority inversion and related
problems.
We have special debug builds which patch the malloc
function, and if
a malloc is detected in the processing thread, we get a very nice
call stack in the debugger which makes it trivial to find
the source
of these problems.



_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/email@hidden

This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/darwin-dev/email@hidden

This email sent to email@hidden
References: 
 >vm_protect with VM_PROT_COPY not working on Leopard (From: "Jeremy Todd" <email@hidden>)
 >Re: vm_protect with VM_PROT_COPY not working on Leopard (From: Chris Sarcone <email@hidden>)
 >RE: vm_protect with VM_PROT_COPY not working on Leopard (From: "Jeremy Todd" <email@hidden>)
 >Re: vm_protect with VM_PROT_COPY not working on Leopard (From: Eric Gouriou <email@hidden>)
 >RE: vm_protect with VM_PROT_COPY not working on Leopard (From: "Jeremy Todd" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.