[PATCH] D52933: Fix incorrect Twine usage in CFGPrinter

Marcin Copik via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 7 04:20:56 PDT 2018


mcopik added a comment.

@kristina thank you for the comment. I think that @grosser has already explain the problem in details, including the reference to docs which explicitly warns before storing Twines constructed with temporaries. Furthermore, Twine documentation in Twine.h states: " A Twine is not intended for use directly and should not be stored, its implementation relies on the ability to store pointers to temporary stack objects which may be deallocated at the end of a statement.". I verified this statement by inspecting Twine implementation and I found out that Twine does not capture nor copy the provided objects but always takes a pointer .

As a result, the statement in line 175 creates a Twine object which internally holds pointers to a Twine instance for weight value which was a temporary object on the stack that might be destroyed after execution moves to statement in line 176.

This bus was also discovered by someone else before: https://bugs.llvm.org/show_bug.cgi?id=37019 and it was fixed in a similar fashion in the llvmlite project https://github.com/numba/llvmlite/pull/343


Repository:
  rL LLVM

https://reviews.llvm.org/D52933





More information about the llvm-commits mailing list