ggc_collect() discarding/reusing remap_debug_filename() output, thus producing invalid objects
Florian Weimer
fw@deneb.enyo.de
Tue Mar 19 18:27:00 GMT 2019
* Thomas Otto:
>> > I tried to annotate `cached_wd` via GTY((..)) as on first glance it seems
>> > the gc mistakenly re-uses it, but the `gengtype` generated state file never
>> > picks this variable up.
>>
>> Have you tried moving the variable to the top level and annotating it
>> with GTY ((cache))?
>>
>> I believe gengtype will emit code to clear such variables during
>> garbage collection, avoiding the issue.
>
> Thanks, `static GTY(()) const char* cached_wd = NULL;` outside the
> function fixes it. (style: Is directly outside the function Ok, or
> should this be moved to the top of the file?)
Just move it before the the function and add a comment how it is used
(only in the following function). There's a similar example in
varasm.c at least.
> Now gtype.state picks it up and the final object contains the
> correct string.
Nice. Would you be willing to send a patch to gcc-patches?
More information about the Gcc-help
mailing list