Page MenuHome

Fix T81340: UBSan: load of value .. not a valid type for IDRecalcFlag
AbandonedPublic

Authored by Ankit Meel (ankitm) on Oct 1 2020, 1:17 AM.

Details

Summary

The value of flag is (-8392830)10 (ff7fef82)16, which points to
the problem in deg_builder.cc:237: flag |= id_orig->recalc; where
recalc is -8392830. That is a separate issue.

bitscan_forward_clear_i keeps reducing the value of current_flag
until the sign bit is cleared and long before that, the underlying
type of the enum overflows.

The warning:
depsgraph_tag.cc:367:7: runtime error: load of value 33554432, which
is not a valid value for type 'IDRecalcFlag'

Fix T81340 (partially)

Diff Detail

Repository
rB Blender
Branch
ubdeg (branched from master)
Build Status
Buildable 10498
Build 10498: arc lint + arc unit

Event Timeline

Ankit Meel (ankitm) requested review of this revision.Oct 1 2020, 1:17 AM
Ankit Meel (ankitm) created this revision.
Campbell Barton (campbellbarton) added inline comments.
source/blender/depsgraph/intern/depsgraph_tag.cc
662–666

Since it's possible we some day use (1 << 32u) in IDRecalcFlag , wouldn't it be more future proof to use a uint here?

Ankit Meel (ankitm) abandoned this revision.EditedOct 1 2020, 8:27 AM

There are other problems in IDRecalcFlag related code and this patch is a duct tape.
Why does one part of the code do flag |= -8392830; ?
If all enumerators are positive, why not assert (or print a log at least) if a negative flag appears?
(minor) Why not use const for arguments ?

I'd rather abandon this and let someone else create a better fix.