This is the mail archive of the libffi-discuss@sourceware.org mailing list for the libffi project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Win64: Fwd: [PATCH] Don't replace avalue with stack memory


This is repost. This is *critical bug* for Win64 code.

BTW, who is win64 code written?
Also, CPython uses libffi_msvc, so they don't use this implementation.


-- Makoto


Makoto Kato wrote:
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>



Attachment: 0001-PATCH-Don-t-replace-avalue-with-stack-memory.patch
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]