Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YAML IO crashes in Input::beginMapping() when trying to read from an empty string #16299

Closed
llvmbot opened this issue May 7, 2013 · 3 comments
Labels
bugzilla

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented May 7, 2013

Bugzilla Link 15927
Resolution FIXED
Resolved on Nov 18, 2013 09:51
Version trunk
OS Linux
Reporter LLVM Bugzilla Contributor
CC @eugenis,@kcc

Extended Description

The code to reproduce this is:
#include "llvm/Support/YAMLTraits.h"
struct T { int a; };

namespace llvm {
namespace yaml {
template <> struct MappingTraits {
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(CurrentNode);

@kcc
Copy link
Contributor

kcc commented May 31, 2013

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

@llvmbot
Copy link
Collaborator Author

llvmbot commented May 31, 2013

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.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Nov 18, 2013

Fixed in r195016.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 4, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla
Projects
None yet
Development

No branches or pull requests

2 participants