This is the mail archive of the
libffi-discuss@sourceware.org
mailing list for the libffi project.
Re: Win64: Fwd: [PATCH] Don't replace avalue with stack memory
- From: Makoto Kato <m_kato at ga2 dot so-net dot ne dot jp>
- To: Dan Witte <dwitte at mozilla dot com>, Timothy Wall <twall at users dot sf dot net>
- Cc: libffi-discuss <libffi-discuss at sourceware dot org>
- Date: Wed, 12 May 2010 16:52:56 +0900
- Subject: Re: Win64: Fwd: [PATCH] Don't replace avalue with stack memory
- References: <1106181728.165776.1273609703775.JavaMail.root@cm-mail03.mozilla.org> <2041950337.165784.1273609723794.JavaMail.root@cm-mail03.mozilla.org>
Hi, Dan and Timothy,
There is no dejagnu/expect for mingw32 and mingw64.
But, when I run testsuite with my patch by hand, test suite is all pass.
-- Makoto
On Wed, May 12, 2010 at 5:28 AM, Dan Witte <dwitte@mozilla.com> wrote:
> Ah, I see. Which isn't a problem for any of the other types, since they get pushed on the stack or into registers.
>
> FWIW, it seems natural to me that the args given to ffi_call are stompable.
>
> Attached is a patch to go with Makoto's, adding a comment to the docs and the changelog.
>
> Dan
>
> ----- "Timothy Wall" <twall@users.sf.net> wrote:
>
>> I think the original intent was to avoid allowing the callee to write
>> to any of the original inputs (preserving call by value semantics for
>> a structure). ÂIf the tests still pass without it, it can go away
>> (since no other targets seem to care about it), although something
>> should be put into the documentation about structure arguments passed
>> by value are not necessarily unmodified for the caller.
>>
>>
>> On May 11, 2010, at 11:41 AM, Dan Witte wrote:
>>
>> > Timothy should probably look at this; fwding just to make sure.
>> >
>> > (I've no idea why it copied to the stack in the first place.)
>> >
>> > Cheers,
>> > Dan
>> >
>> >
>> > ----- Forwarded Message -----
>> > From: "Makoto Kato" <m_kato@ga2.so-net.ne.jp>
>> > To: libffi-discuss@sourceware.org
>> > Sent: Monday, May 10, 2010 7:32:02 PM
>> > Subject: [PATCH] Don't replace avalue with stack memory
>> >
>> > Hi, fork.
>> >
>> > ffi_call may overrides avalue when type is structure or long
>> double.
>> > When overriding it, ffi_call doesn't restore it. ÂThe caller don't
>> > know whether it is on stack or on heap, so this may causes heap
>> > corruption.
>> >
>> > I think that it is unnecessary to replace it with stack memory by
>> > alloca(). ÂIf needed, we should restore avalue.
>> >
>> > This is Win64 implementation only.
>> >
>> >
>> > --
>> > Makoto Kato <m_kato@ga2.so-net.ne.jp>
>> > <0001-PATCH-Don-t-replace-avalue-with-stack-memory.patch>
>
--
-- Makoto Kato <m_kato@ga2.so-net.ne.jp>