Message ID | alpine.LNX.2.00.1010081602350.8982@zhemvz.fhfr.qr |
---|---|
State | New |
Headers | show |
On 10/08/2010 10:58 AM, Richard Guenther wrote: > Jason, does this sound like a reasonable workaround (yes, I'll be > eventually looking for a way to avoid the situation in the first place, > but it involves type-merging, a very fragile piece of code ...)? It seems like a fine workaround for release branches, but when ENABLE_CHECKING is on I think we want it to crash as motivation for fixing the real bug. Jason
On Mon, 11 Oct 2010, Jason Merrill wrote: > On 10/08/2010 10:58 AM, Richard Guenther wrote: > > Jason, does this sound like a reasonable workaround (yes, I'll be > > eventually looking for a way to avoid the situation in the first place, > > but it involves type-merging, a very fragile piece of code ...)? > > It seems like a fine workaround for release branches, but when ENABLE_CHECKING > is on I think we want it to crash as motivation for fixing the real bug. Ok, that works for me. I'll wrap the bailout in ENABLE_CHECKING and add an assert if checking is enabled. Thanks, Richard.
On Tue, 12 Oct 2010, Richard Guenther wrote: > On Mon, 11 Oct 2010, Jason Merrill wrote: > > > On 10/08/2010 10:58 AM, Richard Guenther wrote: > > > Jason, does this sound like a reasonable workaround (yes, I'll be > > > eventually looking for a way to avoid the situation in the first place, > > > but it involves type-merging, a very fragile piece of code ...)? > > > > It seems like a fine workaround for release branches, but when ENABLE_CHECKING > > is on I think we want it to crash as motivation for fixing the real bug. > > Ok, that works for me. I'll wrap the bailout in ENABLE_CHECKING and > add an assert if checking is enabled. On a second thought, as the problem happens here: static inline void add_pure_or_virtual_attribute (dw_die_ref die, tree func_decl) { if (DECL_VINDEX (func_decl)) { add_AT_unsigned (die, DW_AT_virtuality, DW_VIRTUALITY_virtual); if (host_integerp (DECL_VINDEX (func_decl), 0)) add_AT_loc (die, DW_AT_vtable_elem_location, new_loc_descr (DW_OP_constu, tree_low_cst (DECL_VINDEX (func_decl), 0), 0)); /* GNU extension: Record what type this method came from originally. */ if (debug_info_level > DINFO_LEVEL_TERSE && DECL_CONTEXT (func_decl)) add_AT_die_ref (die, DW_AT_containing_type, lookup_type_die (DECL_CONTEXT (func_decl))); DECL_CONTEXT is non-NULL but lookup_type_die fails. We can also not emit DW_AT_containing_type if the lookup failed (similar to the DECL_CONTEXT check), or even use force_type_die here. Both work for the testcase. A workaround on the LTO side would be to clear DECL_CONTEXT on such functions. Thanks, Richard.
On 10/18/2010 12:02 PM, Richard Guenther wrote: > DECL_CONTEXT is non-NULL but lookup_type_die fails. We can also > not emit DW_AT_containing_type if the lookup failed (similar to the > DECL_CONTEXT check), or even use force_type_die here. Both work > for the testcase. I guess omitting the attribute when !ENABLE_CHECKING is also ok. > A workaround on the LTO side would be to clear > DECL_CONTEXT on such functions. On which functions? How do you detect on the LTO side that type merging has gone wrong? Jason
On Mon, 18 Oct 2010, Jason Merrill wrote: > On 10/18/2010 12:02 PM, Richard Guenther wrote: > > DECL_CONTEXT is non-NULL but lookup_type_die fails. We can also > > not emit DW_AT_containing_type if the lookup failed (similar to the > > DECL_CONTEXT check), or even use force_type_die here. Both work > > for the testcase. > > I guess omitting the attribute when !ENABLE_CHECKING is also ok. Ok. > > A workaround on the LTO side would be to clear > > DECL_CONTEXT on such functions. > > On which functions? How do you detect on the LTO side that type merging has > gone wrong? On all functions which have a record or union type DECL_CONTEXT (all functions that are in some TYPE_METHODS which we do not stream). Of course I can't detect whether type merging has gone wrong. Richard.
On 10/19/2010 05:13 AM, Richard Guenther wrote: >>> A workaround on the LTO side would be to clear >>> DECL_CONTEXT on such functions. >> >> On which functions? How do you detect on the LTO side that type merging has >> gone wrong? > > On all functions which have a record or union type DECL_CONTEXT > (all functions that are in some TYPE_METHODS which we do not > stream). Of course I can't detect whether type merging has gone wrong. That would be overkill, stipping debug info even when the types are ok. Jason
Index: gcc/dwarf2out.c =================================================================== --- gcc/dwarf2out.c (revision 165169) +++ gcc/dwarf2out.c (working copy) @@ -7335,6 +7335,11 @@ add_AT_die_ref (dw_die_ref die, enum dwa { dw_attr_node attr; + /* With LTO we can end up trying to reference something we didn't create + a DIE for. Avoid crashing later on a NULL referenced DIE. */ + if (targ_die == NULL) + return; + attr.dw_attr = attr_kind; attr.dw_attr_val.val_class = dw_val_class_die_ref; attr.dw_attr_val.v.val_die_ref.die = targ_die;