Bug 324050 (MONO81370) - [PATCH] some LP(C)WSTR marshal weirdness on win32
Summary: [PATCH] some LP(C)WSTR marshal weirdness on win32
Status: RESOLVED FIXED
Alias: MONO81370
Product: Mono: Runtime
Classification: Mono
Component: interop (show other bugs)
Version: 1.0
Hardware: Other Other
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Mono Bugs
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-04-13 15:21 UTC by Atsushi Enomoto
Modified: 2007-09-15 21:24 UTC (History)
0 users

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


Attachments
repro (2.78 KB, text/plain)
2007-04-13 15:22 UTC, Thomas Wiest
Details
Patch (2.83 KB, patch)
2007-05-10 22:35 UTC, Thomas Wiest
Details | Diff
Complete Patch (3.69 KB, patch)
2007-05-10 22:39 UTC, Thomas Wiest
Details | Diff

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


---- Reported by atsushi@ximian.com 2007-04-13 08:21:09 MST ----

During cardspace work I'm getting a weird error which seems to be caused by
marshalling behavioral difference.

Unfortunately this test depends on .NET 3.0 (infocardapi.dll) and thus it
is reproducible only on windows...

I have a structure that looks like:

	[StructLayout (LayoutKind.Sequential, CharSet = CharSet.Unicode)]
	struct NativePolicyElement
	{
		string target;
		string issuer;
		string parameters;
		string privacy_link;
		int privacy_ver;
		bool is_managed;
	}

and a P/Invoke method:

	[DllImport ("infocardapi", CharSet = CharSet.Unicode)]
	static extern int GetToken (int cPolicyChain,
		NativePolicyElement [] pPolicyChain,
		out NativeGenericXmlToken securityToken,
		out NativeInfocardCryptoHandle phProofTokenCrypto);

When I compiled the attached repro with gmcs, and run under .NET, it raises
Infocard selector without errors. When I run the same binary with mono
(win32 runtime), it raises an error saying:

	"Incoming policy failed validation."

It files an application error on win32 EventLog:

<blockquote>
Incoming policy failed validation.  Received policy with invalid epr.

Inner Exception: The data at the root level is invalid. Line 1, position 1.


Additional Information:
Microsoft.InfoCards.PolicyValidationException: Received policy with invalid
epr. ---> System.Xml.XmlException: The data at the root level is invalid.
Line 1, position 1.
...
</blockquote>

(note that there is no invalid XML; .NET runs it just fine).

The error message above refers to "invalid epr", which corresponds to the
"target" field in NativePolicyElement.

Other parameters such as those "out" ones are ignorable (they will cause an
error only after you selected a card) and they can be removed to reproduce
the issue above.



---- Additional Comments From atsushi@ximian.com 2007-04-13 08:22:12 MST ----

Created an attachment (id=171785)
repro




---- Additional Comments From joncham@gmail.com 2007-05-10 15:35:02 MST ----

Created an attachment (id=171786)
Patch




---- Additional Comments From joncham@gmail.com 2007-05-10 15:36:12 MST ----

All runtime tests pass with this patch, and it fixes a bug very
similar to this one in my app. I didn't test since I don't have .Net
3.0 installed. Atsushi, this should fix your issue as well.



---- Additional Comments From joncham@gmail.com 2007-05-10 15:39:34 MST ----

Created an attachment (id=171787)
Complete Patch




---- Additional Comments From vargaz@gmail.com 2007-05-10 18:02:24 MST ----

This looks ok to check in.




---- Additional Comments From atsushi@ximian.com 2007-05-10 22:21:10 MST ----

The patch actually fixed the issue I reported here :-)



---- Additional Comments From joncham@gmail.com 2007-05-10 22:47:07 MST ----

Fixed in r77190.

Imported an attachment (id=171785)
Imported an attachment (id=171786)
Imported an attachment (id=171787)

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