On 02/12/17 10:14, Albert Astals Cid wrote: > Adrian, can you have a look at https://paste.kde.org/pe6yweh7u ? > > It seems we have somehow a bug in that code? Is it something you introduced > or > was it buggy already but just not exercised and now your test reveals the > problem?
The buffer in the test is not large enough. The attached patch increases the buffer size and adds an assert to check the buffer size. I did test it with valgrind when I wrote the test but interestingly it doesn't pick up the problem. The second attached patch updates the INSTALL file to document the use of the address sanitizer.
>From 2fb8acfa7448f36112c25e26464ccb88cad43750 Mon Sep 17 00:00:00 2001 From: Adrian Johnson <[email protected]> Date: Sat, 2 Dec 2017 14:01:42 +1030 Subject: [PATCH 1/2] Fix UTF test fail The buffer size was not large enough. Increase it and add an assert to check the buffer size. --- qt5/tests/check_utf_conversion.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/qt5/tests/check_utf_conversion.cpp b/qt5/tests/check_utf_conversion.cpp index b8eb03a5..d344434d 100644 --- a/qt5/tests/check_utf_conversion.cpp +++ b/qt5/tests/check_utf_conversion.cpp @@ -46,9 +46,9 @@ void TestUTFConversion::testUTF_data() void TestUTFConversion::testUTF() { - char utf8Buf[100]; + char utf8Buf[1000]; char *utf8String; - uint16_t utf16Buf[100]; + uint16_t utf16Buf[1000]; uint16_t *utf16String; int len; @@ -57,8 +57,9 @@ void TestUTFConversion::testUTF() // UTF-8 to UTF-16 - // QString size() returns number of code units, not code points - QCOMPARE( utf8CountUtf16CodeUnits(str), s.size() ); + len = utf8CountUtf16CodeUnits(str); + QCOMPARE( len, s.size() ); // QString size() returns number of code units, not code points + Q_ASSERT( len < (int)sizeof(utf16Buf) ); // if this fails, make utf16Buf larger len = utf8ToUtf16(str, utf16Buf); QVERIFY( compare(utf16Buf, s.utf16()) ); @@ -70,7 +71,9 @@ void TestUTFConversion::testUTF() // UTF-16 to UTF-8 - QCOMPARE( utf16CountUtf8Bytes(s.utf16()), (int)strlen(str) ); + len = utf16CountUtf8Bytes(s.utf16()); + QCOMPARE( len, (int)strlen(str) ); + Q_ASSERT( len < (int)sizeof(utf8Buf) ); // if this fails, make utf8Buf larger len = utf16ToUtf8(s.utf16(), utf8Buf); QVERIFY( compare(utf8Buf, str) ); -- 2.11.0
>From 2360b9039b0e8a61f590fed54a4e43b98f9387a9 Mon Sep 17 00:00:00 2001 From: Adrian Johnson <[email protected]> Date: Sat, 2 Dec 2017 14:13:50 +1030 Subject: [PATCH 2/2] INSTALL: add debug options also ensure cmake commands are lowercase to be consistent with our code style. --- INSTALL | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/INSTALL b/INSTALL index 7b5d6585..a38a8c00 100644 --- a/INSTALL +++ b/INSTALL @@ -65,12 +65,40 @@ tools. Run cmake with the option: A sample toolchain for a 64-bit mingw build is shown below. Replace /path/to/win/root with the install prefix for the target environment. - SET(CMAKE_SYSTEM_NAME Windows) - SET(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) - SET(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) - SET(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres) - SET(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32 /path/to/win/root ) + set(CMAKE_SYSTEM_NAME Windows) + set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc) + set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++) + set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres) + set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32 /path/to/win/root ) set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +Debugging Options +================= + +Debug Build Types +----------------- +Release build with debugging information: + -DCMAKE_BUILD_TYPE=relwithdebinfo + +Debug build with optimization except for some code re-ordering optimizations: + -DCMAKE_BUILD_TYPE=debug + +Debug build with no optimization: + -DCMAKE_BUILD_TYPE=debugfull + +Release build with debugging and profiling information: + -DCMAKE_BUILD_TYPE=profile + + +Address Sanitizer +----------------- +Ensure the extra cmake modules are available (may be a separate +package) then use -DECM_ENABLE_SANITIZERS to specify the santizers. eg + + -DECM_ENABLE_SANITIZERS='address;leak;undefined' + +Some options may only be available with clang. Use +-DCMAKE_CXX_COMPILER=clang++ to build with clang. -- 2.11.0
_______________________________________________ poppler mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/poppler
