Fix PR44284.
This is probably not valid assembly but we should not crash.
Differential D71443
[MC][PowerPC] Fix a crash when redefining a symbol after .set MaskRay on Dec 12 2019, 4:56 PM. Authored by
Details
Fix PR44284. This is probably not valid assembly but we should not crash.
Diff Detail
Event TimelineComment Actions LGTM. It seems I did not consider that Symbol could change its type between when it was added in emitAssignment() and when processed in finish(). Comment Actions @MaskRay @luporl Is it possible for Sym to be null here? Do we need a nullptr check? I ask because we seem to have a crash here reported in https://bugs.llvm.org/show_bug.cgi?id=45366 that we cannot reproduce. But I wonder if perhaps this might be the issue. I have asked the OP of the PR to try the patch that adds the null check, but I was hoping to get your opinion on this as well. Comment Actions In a -DLLVM_ENABLE_ASSERTIONS=on build, Sym can't be nullptr. Might to good to ask the OP of https://bugs.llvm.org/show_bug.cgi?id=45366 whether this can be reproduced void emitAssignment(MCSymbol *S, const MCExpr *Value) override { auto *Symbol = cast<MCSymbolELF>(S); //////////// asserted to be non-null // When encoding an assignment to set symbol A to symbol B, also copy // the st_other bits encoding the local entry point offset. if (copyLocalEntry(Symbol, Value)) UpdateOther.insert(Symbol); ///////// only way an element is inserted into UpdateOther else UpdateOther.erase(Symbol); } Here is the only caller of llvm::MCTargetStreamer::emitAssignment // https://github.com/llvm/llvm-project/blob/master/llvm/lib/MC/MCStreamer.cpp#L966 void MCStreamer::emitAssignment(MCSymbol *Symbol, const MCExpr *Value) { visitUsedExpr(*Value); Symbol->setVariableValue(Value); MCTargetStreamer *TS = getTargetStreamer(); if (TS) TS->emitAssignment(Symbol, Value); //////////// Symbol can't be nullptr } |