Signed-off-by: Zebediah Figura z.figura12@gmail.com --- tools/widl/typegen.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c index e63600c..27855cc 100644 --- a/tools/widl/typegen.c +++ b/tools/widl/typegen.c @@ -3276,6 +3276,7 @@ static unsigned int write_union_tfs(FILE *file, const attr_list_t *attrs, { const var_t *sv = type_union_get_switch_value(type); const type_t *st = sv->type; + unsigned int align = 0; unsigned char fc;
if (type_get_type(st) == TYPE_BASIC) @@ -3303,9 +3304,16 @@ static unsigned int write_union_tfs(FILE *file, const attr_list_t *attrs, else error("union switch type must be an integer, char, or enum\n");
+ type_memsize_and_alignment(st, &align); + if (fields) LIST_FOR_EACH_ENTRY(f, fields, var_t, entry) + { + if (f->type) + type_memsize_and_alignment(f->type, &align); + } + print_file(file, 2, "0x%x,\t/* FC_ENCAPSULATED_UNION */\n", RPC_FC_ENCAPSULATED_UNION); print_file(file, 2, "0x%x,\t/* Switch type= %s */\n", - 0x40 | fc, string_of_type(fc)); + (align << 4) | fc, string_of_type(fc)); *tfsoff += 2; } else if (is_attr(type->attrs, ATTR_SWITCHTYPE))
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/rpcrt4/ndr_marshall.c | 16 ++++++++++++++++ dlls/rpcrt4/tests/server.c | 25 +++++++++++++++++++++++++ dlls/rpcrt4/tests/server.idl | 9 +++++++++ 3 files changed, 50 insertions(+)
diff --git a/dlls/rpcrt4/ndr_marshall.c b/dlls/rpcrt4/ndr_marshall.c index ee58b60..cbe8223 100644 --- a/dlls/rpcrt4/ndr_marshall.c +++ b/dlls/rpcrt4/ndr_marshall.c @@ -5745,6 +5745,10 @@ static unsigned char *union_arm_marshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned c pStubMsg->Buffer = saved_buffer + 4; } break; + case RPC_FC_IP: + /* must be dereferenced first */ + m(pStubMsg, *(unsigned char **)pMemory, desc); + break; default: m(pStubMsg, pMemory, desc); } @@ -5814,6 +5818,10 @@ static unsigned char *union_arm_unmarshall(PMIDL_STUB_MESSAGE pStubMsg, pStubMsg->Buffer = saved_buffer + 4; } break; + case RPC_FC_IP: + /* must be dereferenced first */ + m(pStubMsg, *(unsigned char ***)ppMemory, desc, fMustAlloc); + break; default: m(pStubMsg, ppMemory, desc, fMustAlloc); } @@ -5868,6 +5876,10 @@ static void union_arm_buffer_size(PMIDL_STUB_MESSAGE pStubMsg, pStubMsg->BufferLength = saved_buffer_length; } break; + case RPC_FC_IP: + /* must be dereferenced first */ + m(pStubMsg, *(unsigned char **)pMemory, desc); + break; default: m(pStubMsg, pMemory, desc); } @@ -5955,6 +5967,10 @@ static void union_arm_free(PMIDL_STUB_MESSAGE pStubMsg, case RPC_FC_FP: PointerFree(pStubMsg, *(unsigned char **)pMemory, desc); break; + case RPC_FC_IP: + /* must be dereferenced first */ + m(pStubMsg, *(unsigned char **)pMemory, desc); + break; default: m(pStubMsg, pMemory, desc); } diff --git a/dlls/rpcrt4/tests/server.c b/dlls/rpcrt4/tests/server.c index 31f5c4d..5278a1d 100644 --- a/dlls/rpcrt4/tests/server.c +++ b/dlls/rpcrt4/tests/server.c @@ -844,6 +844,15 @@ void __cdecl s_stop(void) } }
+void __cdecl s_ip_test(ipu_t *a) +{ + STATSTG st; + HRESULT hr; + + hr = IStream_Stat(a->tagged_union.stream, &st, STATFLAG_NONAME); + ok(hr == S_OK, "got %#x\n", hr); +} + static void make_cmdline(char buffer[MAX_PATH], const char *test) { @@ -1044,6 +1053,8 @@ union_tests(void) encu_t eu; unencu_t uneu; sun_t su; + ipu_t ipu; + LONG ref; int i;
su.s = SUN_I; @@ -1084,6 +1095,15 @@ union_tests(void) eue.t = E2; eue.tagged_union.f2 = 10.0; ok(square_encue(&eue) == 100.0, "RPC square_encue\n"); + + CoInitializeEx(NULL, COINIT_MULTITHREADED); + + CreateStreamOnHGlobal(NULL, TRUE, &ipu.tagged_union.stream); + ip_test(&ipu); + ref = IStream_Release(ipu.tagged_union.stream); + ok(!ref, "got %u refs\n", ref); + + CoUninitialize(); }
static test_list_t * @@ -1701,6 +1721,9 @@ server(void) RPC_STATUS status, iptcp_status, np_status, ncalrpc_status; DWORD ret;
+ /* needed for tests involving interface pointers */ + CoInitializeEx(NULL, COINIT_MULTITHREADED); + iptcp_status = RpcServerUseProtseqEpA(iptcp, 20, port, NULL); ok(iptcp_status == RPC_S_OK, "RpcServerUseProtseqEp(ncacn_ip_tcp) failed with status %d\n", iptcp_status);
@@ -1766,6 +1789,8 @@ server(void)
CloseHandle(stop_event); stop_event = NULL; + + CoUninitialize(); }
static DWORD WINAPI listen_test_client_thread(void *binding) diff --git a/dlls/rpcrt4/tests/server.idl b/dlls/rpcrt4/tests/server.idl index 8a02c29..75d78f7 100644 --- a/dlls/rpcrt4/tests/server.idl +++ b/dlls/rpcrt4/tests/server.idl @@ -21,6 +21,8 @@ #pragma makedep client #pragma makedep server
+import "objidl.idl"; + #include "server_defines.h"
typedef struct tag_vector @@ -383,4 +385,11 @@ cpp_quote("#endif") void authinfo_test(unsigned int protseq, int secure);
void stop(void); + + typedef union ipu switch(int t) + { + default: IStream *stream; + } ipu_t; + + void ip_test([in] ipu_t *a); }
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check? Full results can be found at https://testbot.winehq.org/JobDetails.pl?Key=37602
Your paranoid android.
=== wvistau64 (64 bit ndr_marshall) === TestBot process died unexpectedly
=== wvistau64 (64 bit server) === 0608:server: unhandled exception c0000005 at 000007FEFEE110EF 0930:server: unhandled exception c0000005 at 000007FEFEE110EF 0250:server: unhandled exception c0000005 at 000007FEFEE110EF server.c:1781: Test failed: WaitForSingleObject
=== w7pro64 (64 bit server) === 0ad4:server: unhandled exception c0000005 at 000007FEFD76F0FF 0af8:server: unhandled exception c0000005 at 000007FEFD76F0FF 0b20:server: unhandled exception c0000005 at 000007FEFD76F0FF server.c:1781: Test failed: WaitForSingleObject The previous 4 run(s) terminated abnormally
=== w864 (64 bit server) === 074c:server: unhandled exception c0000005 at 00007FFB253D6836 07c8:server: unhandled exception c0000005 at 00007FFB253D6836 0d0c:server: unhandled exception c0000005 at 00007FFB253D6836 server.c:1781: Test failed: WaitForSingleObject
=== w1064 (64 bit server) === 0f28:server: unhandled exception c0000005 at 00007FFC3B7B0140 0118:server: unhandled exception c0000005 at 00007FFC3B7B0140 0f3c:server: unhandled exception c0000005 at 00007FFC3B7B0140 server.c:1781: Test failed: WaitForSingleObject
On 10/04/18 20:49, Marvin wrote:
Hi,
While running your changed tests on Windows, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check? Full results can be found at https://testbot.winehq.org/JobDetails.pl?Key=37602
Your paranoid android.
=== wvistau64 (64 bit ndr_marshall) === TestBot process died unexpectedly
=== wvistau64 (64 bit server) === 0608:server: unhandled exception c0000005 at 000007FEFEE110EF 0930:server: unhandled exception c0000005 at 000007FEFEE110EF 0250:server: unhandled exception c0000005 at 000007FEFEE110EF server.c:1781: Test failed: WaitForSingleObject
=== w7pro64 (64 bit server) === 0ad4:server: unhandled exception c0000005 at 000007FEFD76F0FF 0af8:server: unhandled exception c0000005 at 000007FEFD76F0FF 0b20:server: unhandled exception c0000005 at 000007FEFD76F0FF server.c:1781: Test failed: WaitForSingleObject The previous 4 run(s) terminated abnormally
=== w864 (64 bit server) === 074c:server: unhandled exception c0000005 at 00007FFB253D6836 07c8:server: unhandled exception c0000005 at 00007FFB253D6836 0d0c:server: unhandled exception c0000005 at 00007FFB253D6836 server.c:1781: Test failed: WaitForSingleObject
=== w1064 (64 bit server) === 0f28:server: unhandled exception c0000005 at 00007FFC3B7B0140 0118:server: unhandled exception c0000005 at 00007FFC3B7B0140 0f3c:server: unhandled exception c0000005 at 00007FFC3B7B0140 server.c:1781: Test failed: WaitForSingleObject
A successful test using recompiled widl from patch 1/4 is here:
Signed-off-by: Huw Davies huw@codeweavers.com
Because it's not a type, but the lack of one.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/rpcrt4/ndr_marshall.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/dlls/rpcrt4/ndr_marshall.c b/dlls/rpcrt4/ndr_marshall.c index cbe8223..6356fb9 100644 --- a/dlls/rpcrt4/ndr_marshall.c +++ b/dlls/rpcrt4/ndr_marshall.c @@ -5753,7 +5753,8 @@ static unsigned char *union_arm_marshall(PMIDL_STUB_MESSAGE pStubMsg, unsigned c m(pStubMsg, pMemory, desc); } } - else FIXME("no marshaller for embedded type %02x\n", *desc); + else if (*desc) + FIXME("no marshaller for embedded type %02x\n", *desc); } return NULL; } @@ -5826,7 +5827,8 @@ static unsigned char *union_arm_unmarshall(PMIDL_STUB_MESSAGE pStubMsg, m(pStubMsg, ppMemory, desc, fMustAlloc); } } - else FIXME("no marshaller for embedded type %02x\n", *desc); + else if (*desc) + FIXME("no marshaller for embedded type %02x\n", *desc); } return NULL; } @@ -5884,7 +5886,8 @@ static void union_arm_buffer_size(PMIDL_STUB_MESSAGE pStubMsg, m(pStubMsg, pMemory, desc); } } - else FIXME("no buffersizer for embedded type %02x\n", *desc); + else if (*desc) + FIXME("no buffersizer for embedded type %02x\n", *desc); } }
@@ -5932,7 +5935,8 @@ static ULONG union_arm_memory_size(PMIDL_STUB_MESSAGE pStubMsg, return m(pStubMsg, desc); } } - else FIXME("no marshaller for embedded type %02x\n", *desc); + else if (*desc) + FIXME("no marshaller for embedded type %02x\n", *desc); }
TRACE("size %d\n", size);
Signed-off-by: Huw Davies huw@codeweavers.com
This was an inconsistency I noticed while testing the previous patches.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- tools/widl/typegen.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/tools/widl/typegen.c b/tools/widl/typegen.c index 27855cc..9f62589 100644 --- a/tools/widl/typegen.c +++ b/tools/widl/typegen.c @@ -3248,6 +3248,7 @@ static unsigned int write_union_tfs(FILE *file, const attr_list_t *attrs, unsigned int nbranch = 0; type_t *deftype = NULL; short nodeftype = 0xffff; + unsigned int dummy; var_t *f;
if (processed(type) && @@ -3256,10 +3257,10 @@ static unsigned int write_union_tfs(FILE *file, const attr_list_t *attrs,
guard_rec(type);
- size = type_memsize(type); - fields = type_union_get_cases(type);
+ size = union_memsize(fields, &dummy); + if (fields) LIST_FOR_EACH_ENTRY(f, fields, var_t, entry) { expr_list_t *cases = get_attrp(f->attrs, ATTR_CASE);
On Tue, Apr 10, 2018 at 08:30:29PM -0500, Zebediah Figura wrote:
This was an inconsistency I noticed while testing the previous patches.
Wine's rpcrt4 does the right thing here, so we were in effect allocating too much memory.
Signed-off-by: Huw Davies huw@codeweavers.com