logSelection.cpp : too high tag values show up in some jtreg tests

Stefan Karlsson stefan.karlsson at oracle.com
Wed Sep 25 15:36:36 UTC 2024


Hi Matthias,

On 2024-09-25 15:38, Baesken, Matthias wrote:
>
> Hi Stefan, not sure if this is the cause of the issue. If I add a 
> check with a guarantee and build/run without ubsan
>
> @@ -46,6 +46,9 @@ bool 
> LogSelectionList::verify_selections(outputStream* out) const {
>        _selections[i].describe_tags_on(out);
>        out->print(". ");
>
> + // added - check that the array entries are okay
> + _selections[i].check_for_bad_tag_array(i, out);
> +
>        _selections[i].suggest_similar_matching(out);
>
> I see the large  tag entry values too.
>

I'm pretty sure the lack of initialization is the problem and I don't 
see how the above shows that claim to be false.

> But initializing the whole  _tags  array seems to make sense.
>
> What value should we write  to the entries  ?
>

I think we can either set them to LogTag::__NO_TAG, or rely on the fact 
that __NO_TAG is equal to 0 and just add `_ntags()` to the intialization 
list to get the array value initialized (which will zero initialize the 
elements, IIUC).

> And any idea why the initialization was not done for some  ?
>

I added an assert in the LogSelection constructor and it points to:
     LogSelection exact_selection(subsets[i], false, level);

Another example is the LogSelection::LogSelection(). To find the exact 
place in these tests I would recommend using the rr tool to reverse 
debug to the point where _tags[0] was initialized.

Cheers,
StefanK

> Best regards, Matthias
>
> *>*
>
> >Isn't the problem that the LogSelection constructor doesn't 
> initialize all elements (Only elements that are __NO_TAG gets 
> initialized):
> >```
> >LogSelection::LogSelection(const LogTagType tags[LogTag::MaxTags], 
> bool wildcard, LogLevelType level)
> >    : _ntags(0), _wildcard(wildcard), _level(level), 
> _tag_sets_selected(0) {
> >  while (_ntags < LogTag::MaxTags && tags[_ntags] != LogTag::__NO_TAG) {
> >    _tags[_ntags] = tags[_ntags];
> >    _ntags++;
> >  }
> >```
> >
> >And then later when the code copies LogTagType arrays, it hits this 
> ubsan warning when it reads the uninitialized value.. It looks like 
> this could be fixed by always fully initializing _tags memory.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/hotspot-runtime-dev/attachments/20240925/cc9e985b/attachment-0001.htm>


More information about the hotspot-runtime-dev mailing list