Unknown constant pointer type error when using BlockAddress

Hi, all

I try to run codes below to get a block address (not entry block)

BasicBlock *bb = BasicBlock::Create(context, "label", func);
Value *alloca = builder.CreateAlloca(builder.getInt8PtrTy(), 0);
builder.CreateStore(BlockAddress::get(bb), alloca);

But every time I get an error:

Unknown constant pointer type!
UNREACHABLE executed at /tmp/llvm20150903-18194-1kmlx72/llvm-3.6.2.src/lib/ExecutionEngine/ExecutionEngine.cpp:825!
Abort trap: 6

It is wired that this problem only happens if I use ExecutableEngine.runFunctionAsMain to run func
If I dump my codes to a llvm IR file first and use llvm tool lli to run IR file, it works

Is it a just-in-time problem ? I am confused.

Thanks, Allen.

Are you mixing context objects? That might cause a weird issue like this.