tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] test failures on win32 x86-64


From: Domingo Alvarez Duarte
Subject: Re: [Tinycc-devel] test failures on win32 x86-64
Date: Wed, 19 Oct 2022 16:06:35 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2

Hello Michael !

Thank you for your great work !

I applied your changes to my fork but the tests continue to fail on window see the result here https://github.com/mingodad/tinycc/actions/runs/3282234645/jobs/5405354710 .

Cheers !

On 19/10/22 14:36, Michael Matz wrote:
Hello,


On Fri, 14 Oct 2022, avih via Tinycc-devel wrote:

0x00007ff72b42b266 <+50>: repnz scas %es:(%rdi),%al
0x00007ff72b42b268 <+52>: dec %edi

This is the problem.  "dec %edi" truncates the %rdi register to 32bit by zero-extension, so that ...

0x00007ff72b42b26a <+54>: mov 0x30(%rbp),%ecx
0x00007ff72b42b26d <+57>: dec %ecx
0x00007ff72b42b26f <+59>: js 0x7ff72b42b277 <strncat1+67>
0x00007ff72b42b271 <+61>: lods %ds:(%rsi),%al
=> 0x00007ff72b42b272 <+62>: stos %al,%es:(%rdi)

... this insn now segfault.  That only matters if the stack (which %rdi points into) is setup such that it's beyond 32bit, which ...

rdi 0xcb9ff955 3416258901
rbp 0x4ecb9ff8f0 0x4ecb9ff8f0
rsp 0x4ecb9ff8e0 0x4ecb9ff8e0

... is indeed the case on win10 for you.  So, it's not malloc() result, but it does have to do with address space layout.

The problem is that win64 is an IL32 platform, so that 'long' is not the same size as a pointer, but the strncat1 implementation, coming from the linux kernel, expects that to be the case.  The below patch should fix it, but I can't test on win64, so please check yourself and commit if it does.


Ciao,
Michael.

----------------------------------------------

diff --git a/tests/tcctest.c b/tests/tcctest.c
index f5bd9aab..1d625b0c 100644
--- a/tests/tcctest.c
+++ b/tests/tcctest.c
@@ -3254,7 +3254,7 @@ void local_label_test(void)
 /* from linux kernel */
 static char * strncat1(char * dest,const char * src,size_t count)
 {
-long d0, d1, d2, d3;
+size_t d0, d1, d2, d3;
 __asm__ __volatile__(
        "repne\n\t"
        "scasb\n\t"
@@ -3276,7 +3276,7 @@ return dest;

 static char * strncat2(char * dest,const char * src,size_t count)
 {
-long d0, d1, d2, d3;
+size_t d0, d1, d2, d3;
 __asm__ __volatile__(
        "repne scasb\n\t" /* one-line repne prefix + string op */
        "dec %1\n\t"

_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel



reply via email to

[Prev in Thread] Current Thread [Next in Thread]