tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] Segfault on arm64 when making a function call with ma


From: Christian Jullien
Subject: Re: [Tinycc-devel] Segfault on arm64 when making a function call with many arguments
Date: Sat, 19 Jun 2021 08:57:28 +0200

Hi just quickly tested on my RPi arm64.

I don’t know if it works, i.e. all arguments go to the right parameter with the right value but, at least it no longer segfault.

 

I’ll make more tests today.

 

C.

 

From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=orange.fr@nongnu.org] On Behalf Of pursuer2 via Tinycc-devel
Sent: Saturday, June 19, 2021 08:28
To: jullien; tinycc-devel
Cc: pursuer2
Subject: Re: [Tinycc-devel] Segfault on arm64 when making a function call with many arguments

 

This bug may caused by "vpushv" SValue with VT_CMP flag. There should be only one VT_CMP SValue on vstack. 

I make below patch to fix it, then the compilation exit normally. But I have no arm64 device with GNU/Linux to verify the test. 

 

diff --git a/arm64-gen.c b/arm64-gen.c

index 6389409..a9cbfa2 100644

--- a/arm64-gen.c

+++ b/arm64-gen.c

@@ -1017,6 +1017,9 @@ ST_FUNC void gfunc_call(int nb_args)

     if (stack >> 12)

             o(0xd14003ff | (stack >> 12) << 10);

 

+    if((vtop->r&VT_VALMASK)==VT_CMP){

+        gv(RC_INT);

+    }

     // First pass: set all values on stack

     for (i = nb_args; i; i--) {

         vpushv(vtop - nb_args + i);

 

 

------------------ Original ------------------

From: "jullien" <eligis@orange.fr>;

Date: Fri, Jun 18, 2021 04:04 PM

To: "tinycc-devel"<tinycc-devel@nongnu.org>;

Subject: Re: [Tinycc-devel] Segfault on arm64 when making a function call with many arguments

 

I confirm it fails on arm64 (but works on arm 32bits).

It also fails with complete prototype:

 

void map_add(int a, int b, int c, int d, int e, int f, int g, int h, int i)

{}

 

C.

 

From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=orange.fr@nongnu.org] On Behalf Of Arthur Williams
Sent: Wednesday, June 16, 2021 20:18
To: tinycc-devel@nongnu.org
Subject: [Tinycc-devel] Segfault on arm64 when making a function call with many arguments

 

Was trying to compile vim with tcc on arm64 but got a segfault. I can simplify it to the following case:

  void map_add(){}
  void main() {
    int A;
    int B;
    map_add(0, 0, 0, 0, 0, 0, 0, 0, A && B); // segfaults when compiling

  }

 

The bad pointer was generated in arm64-gen.c::gsym_addr and the actual segfault occurred in tcc.h::read16le.

Removing one of the 0s or removing A/B or replacing A && B with a constant avoids the problem. Cannot repro on x86. I'm running musl on Linux and using the latest tcc from mob.

 


reply via email to

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