Bug#835606: polly pulls in outdated bundled jsoncpp headers

James Clarke jrtc27 at jrtc27.com
Sat Aug 27 14:39:37 UTC 2016


Source: llvm-toolchain-3.8
Version: 1:3.8.1-9
Severity: important
Tags: patch
Control: clone -1 -2
Control: reassign -2 llvm-toolchain-3.9 1:3.9~+rc3-1~exp1

Hi,
I tracked down the cause of the 27 unexpected failures in check-polly in
most architectures (big-endian architectures have other unrelated ones
too) which crash (hence the stack dump): while polly is *linked* against
the system libjsoncpp, the *bundled* headers are being used. Since
libjsoncpp has had ABI-incompatible changes between the bundled and
system versions (the one I found was that Json::Value has two new
ptrdiff_t fields at the end, increasing its size by 16 bytes, but there
could well be more), things go badly wrong in JSONExporter.cpp. With my
Json::Value example, g++ does not allocate enough stack space for a
local variable, so the new ptrdiff_t fields overlap in memory with other
things (I've seen one overlap with an end iterator, which gets trampled
over, causing the loop to keep going when it shouldn't, and also one
overlap with a pointer that gets freed when going out of scope, which
was also trampled over, causing free to be called on the ptrdiff_t
field).

I have attached an updated version of use-deb-json.diff which uses the
system include paths. Note that I hard-coded the include path to
/usr/include/jsoncpp for the non-cmake build (and it's untested); given
that 3.9 only uses CMake, I didn't bother to do it "properly"
(presumably pkg-config would be the way to go), and the non-cmake bits
will need to be removed for 3.9.

Regards,
James
-------------- next part --------------
Index: b/polly/lib/Makefile
===================================================================
--- a/polly/lib/Makefile
+++ b/polly/lib/Makefile
@@ -26,9 +26,9 @@
                    CodeGen/IslNodeBuilder.cpp \
                    CodeGen/CodeGeneration.cpp
 
-POLLY_JSON_FILES= JSON/json_reader.cpp \
-                  JSON/json_value.cpp \
-                  JSON/json_writer.cpp
+#POLLY_JSON_FILES= JSON/json_reader.cpp \
+#                  JSON/json_value.cpp \
+#                  JSON/json_writer.cpp
 
 ISL_FILES= External/isl/basis_reduction_tab.c \
            External/isl/isl_aff.c \
@@ -146,4 +146,5 @@
 #
 include $(LEVEL)/Makefile.common
 
-LIBS += $(POLLY_LD) $(POLLY_LIB)
+LIBS += $(POLLY_LD) $(POLLY_LIB) -ljsoncpp
+
Index: b/polly/lib/CMakeLists.txt
===================================================================
--- a/polly/lib/CMakeLists.txt
+++ b/polly/lib/CMakeLists.txt
@@ -1,10 +1,10 @@
 set(LLVM_NO_RTTI 1)
 
-set(POLLY_JSON_FILES
-    JSON/json_reader.cpp
-    JSON/json_value.cpp
-    JSON/json_writer.cpp
-)
+# set(POLLY_JSON_FILES
+#     JSON/json_reader.cpp
+#     JSON/json_value.cpp
+#     JSON/json_writer.cpp
+# )
 
 set(ISL_CODEGEN_FILES
     CodeGen/IslAst.cpp
@@ -46,7 +46,7 @@
   Support/RegisterPasses.cpp
   Support/ScopHelper.cpp
   Support/ScopLocation.cpp
-  ${POLLY_JSON_FILES}
+#  ${POLLY_JSON_FILES}
   Transform/Canonicalization.cpp
   Transform/CodePreparation.cpp
   Transform/DeadCodeElimination.cpp
@@ -54,7 +54,7 @@
   ${POLLY_HEADER_FILES}
   )
 
-target_link_libraries(Polly PollyISL)
+target_link_libraries(Polly PollyISL jsoncpp)
 
 if (BUILD_SHARED_LIBS)
   target_link_libraries(Polly
Index: b/polly/CMakeLists.txt
===================================================================
--- a/polly/CMakeLists.txt
+++ b/polly/CMakeLists.txt
@@ -128,10 +128,13 @@
   INCLUDE_DIRECTORIES( ${CUDALIB_INCLUDE_DIR} )
 endif(CUDALIB_FOUND)
 
+find_path(JSONCPP_INCLUDE_PATH json/json.h PATH_SUFFIXES jsoncpp)
+
 include_directories(
   BEFORE
   ${CMAKE_CURRENT_SOURCE_DIR}/include
-  ${CMAKE_CURRENT_SOURCE_DIR}/lib/JSON/include
+#  ${CMAKE_CURRENT_SOURCE_DIR}/lib/JSON/include
+  ${JSONCPP_INCLUDE_PATH}
   ${CMAKE_CURRENT_BINARY_DIR}/lib/External/isl/include
   ${CMAKE_CURRENT_SOURCE_DIR}/lib/External/isl/include
   ${CMAKE_CURRENT_BINARY_DIR}/include
Index: b/polly/Makefile.config.in
===================================================================
--- a/polly/Makefile.config.in
+++ b/polly/Makefile.config.in
@@ -53,7 +53,7 @@
 POLLY_INC :=  @cuda_inc@ \
               -I$(POLLY_OBJ_ROOT)/lib/External/isl/include \
               -I$(POLLY_OBJ_ROOT)/lib/External/isl \
-              -I$(POLLY_SRC_ROOT)/lib/JSON/include \
+              -I/usr/include/jsoncpp \
               -I$(POLLY_SRC_ROOT)/lib/External/isl/include \
               -I$(POLLY_SRC_ROOT)/lib/External/isl/imath \
               -I$(POLLY_SRC_ROOT)/lib/External/isl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-llvm-team/attachments/20160827/589ab649/attachment.sig>


More information about the Pkg-llvm-team mailing list