LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 15927 - YAML IO crashes in Input::beginMapping() when trying to read from an empty string
Summary: YAML IO crashes in Input::beginMapping() when trying to read from an empty st...
Status: RESOLVED FIXED
Alias: None
Product: new-bugs
Classification: Unclassified
Component: new bugs (show other bugs)
Version: trunk
Hardware: PC Linux
: P normal
Assignee: Nick Kledzik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-07 11:48 PDT by Alexander Kornienko
Modified: 2013-11-18 09:51 PST (History)
5 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Kornienko 2013-05-07 11:48:51 PDT
The code to reproduce this is:
#include "llvm/Support/YAMLTraits.h"
struct T { int a; };

namespace llvm {
namespace yaml {
template <> struct MappingTraits<T> {
  static void mapping(llvm::yaml::IO &IO, T &T) {
    IO.mapOptional("a", T.a);
  }
};
}
}

int main(int argc, const char **argv) {
  llvm::yaml::Input Input("");
  T T;
  Input >> T;
  return 0;
}

-----------------
$ ./test
test: llvm/include/llvm/Support/Casting.h:97: static bool llvm::isa_impl_cl<llvm::yaml::Input::MapHNode, const llvm::yaml::Input::HNode *>::doit(const From *) [To = llvm::yaml::Input::MapHNode, From = const llvm::yaml::Input::HNode *]: Assertion `Val && "isa<> used on a null pointer"' failed.
Aborted (core dumped)

The problem is in the line 88 of lib/Support/YAMLTraits.cpp:
88   MapHNode *MN = dyn_cast<MapHNode>(CurrentNode);
Comment 1 Kostya Serebryany 2013-05-31 09:39:08 PDT
I observe the same assertion when compiling a simple .c test with msan:

typedef char int8_t;
int8_t a;
b;
c;
int8_t
fn1 (p1) {
  return a < 0 || p1 || 0 > 1 >> p1 ? a : a << p1;
}
fn2 () {
  int8_t d;
  c = fn1 (b << 13);
  d = c < 0 ? : 0;
  fn3 (d);
}


% clang -c  -O3 -g -fsanitize=memory j.c 

llvm/include/llvm/Support/Casting.h:97: static bool llvm::isa_impl_cl<llvm::ConstantSDNode, const llvm::SDNode *>::doit(const From *) [To = llvm::ConstantSDNode, From = const llvm::SDNode *]: Assertion `Val && "isa<> used on a null pointer"' failed.
11 clang-3.3       0x0000000000b62eed llvm::SelectionDAG::Combine(llvm::CombineLevel, llvm::AliasAnalysis&, llvm::CodeGenOpt::Level) + 733
12 clang-3.3       0x0000000000c1f3a7 llvm::SelectionDAGISel::CodeGenAndEmitDAG() + 871
13 clang-3.3       0x0000000000c1e7d9 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) + 6265
14 clang-3.3       0x0000000000c1c2a6 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 1302
15 clang-3.3       0x0000000000d6d30d llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 125
Comment 2 Alexander Kornienko 2013-05-31 15:04:58 PDT
(In reply to comment #1)
> I observe the same assertion when compiling a simple .c test with msan:
This means there's another wrong usage of isa<> function, but this is an absolutely unrelated issue.
Comment 3 Alexander Kornienko 2013-11-18 09:51:03 PST
Fixed in r195016.