[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Tinycc-devel] tcc segfaults with complex struct initialization
From: |
Michael Matz |
Subject: |
Re: [Tinycc-devel] tcc segfaults with complex struct initialization |
Date: |
Thu, 24 Mar 2016 17:43:58 +0100 (CET) |
User-agent: |
Alpine 2.20 (LSU 67 2015-01-07) |
Hi,
On Wed, 16 Mar 2016, Assaf Gordon wrote:
> $ git clone git://git.sv.gnu.org/coreutils.git && cd coreutils
> $ ./bootstrap
> $ ./configure --without-selinux CC=tcc
> $ make V=1
Thanks for the report.
> The offending code is a complex struct initialization, perhaps related to
> recent discussion:
> http://lists.nongnu.org/archive/html/tinycc-devel/2016-03/msg00042.html
Not directly, it's more an extension in that our initializer parsing is
heavily confused when some initializers are structs themself. I.e. the
particular situation TCC stumbles upon is:
struct S { long j;};
struct T { struct S t;};
struct S ts = {0};
void foo (void)
{
struct T its = { ts };
}
So, the struct field its.t (of type struct S) is supposed to be
initialized by the variable ts (also of type struct S). But our struct
initializer parsing is confused, recursing eagerly into the LHS its.struct
S, seeing member its.S.j of type long and then is surprised that the
initializer for this long is of type 'struct S' (namely still the ts
variable).
I.e. either there's lock-step recursion missing (i.e. when going into
its.S.j it should also go into ts.j), or detection of the situation that a
struct initializer can also be a full struct itself. The latter seems
more correct and easier, but the routines are a slight mess, so I'd need
to think a bit about this (or wait for somebody else :) ).
(I do think we had some other reports about this or similar situations as
well).
Ciao,
Michael.