mesa/src/util
Michel Dänzer 69420c28bd util: Use uint64_t for shifting left in sign_extend and strunc
Shifting int64_t values left into the sign bit has undefined behaviour:

../src/util/fast_idiv_by_const.c:175:14: runtime error: left shift of 131 by 56 places cannot be represented in type 'long int'
    #0 0x561337ed10c1 in sign_extend ../src/util/fast_idiv_by_const.c:175
    #1 0x561337ed1335 in util_compute_fast_sdiv_info ../src/util/fast_idiv_by_const.c:239
    #2 0x561337e17519 in fast_idiv_by_const_int8_Test::TestBody() ../src/util/tests/fast_idiv_by_const/fast_idiv_by_const_test.cpp:357
    #3 0x561337ea815d in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) ../src/gtest/src/gtest.cc:2402
    #4 0x561337e93a6b in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) ../src/gtest/src/gtest.cc:2438
    #5 0x561337e38e75 in testing::Test::Run() ../src/gtest/src/gtest.cc:2474
    #6 0x561337e3b54e in testing::TestInfo::Run() ../src/gtest/src/gtest.cc:2656
    #7 0x561337e3dcdc in testing::TestCase::Run() ../src/gtest/src/gtest.cc:2774
    #8 0x561337e596b6 in testing::internal::UnitTestImpl::RunAllTests() ../src/gtest/src/gtest.cc:4649
    #9 0x561337eabd76 in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) ../src/gtest/src/gtest.cc:2402
    #10 0x561337e97443 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) ../src/gtest/src/gtest.cc:2438
    #11 0x561337e50cd8 in testing::UnitTest::Run() ../src/gtest/src/gtest.cc:4257
    #12 0x561337ed0b91 in RUN_ALL_TESTS() ../src/gtest/include/gtest/gtest.h:2233
    #13 0x561337ed0a51 in main ../src/gtest/src/gtest_main.cc:37
    #14 0x7f85ba483bba in __libc_start_main ../csu/libc-start.c:308
    #15 0x561337e14dc9 in _start (/home/daenzer/src/mesa-git/mesa/build-amd64-sanitize/src/util/tests/fast_idiv_by_const/fast_idiv_by_const_test+0x96dc9)

../src/util/tests/fast_idiv_by_const/fast_idiv_by_const_test.cpp:51:14: runtime error: left shift of negative value -63
    #0 0x55fc3c0e67cc in strunc ../src/util/tests/fast_idiv_by_const/fast_idiv_by_const_test.cpp:51
    #1 0x55fc3c0e6d93 in smul_high ../src/util/tests/fast_idiv_by_const/fast_idiv_by_const_test.cpp:140
    #2 0x55fc3c0e7067 in fast_sdiv ../src/util/tests/fast_idiv_by_const/fast_idiv_by_const_test.cpp:181
    #3 0x55fc3c0e858b in fast_idiv_by_const_int8_Test::TestBody() ../src/util/tests/fast_idiv_by_const/fast_idiv_by_const_test.cpp:358
    #4 0x55fc3c17915d in void testing::internal::HandleSehExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) ../src/gtest/src/gtest.cc:2402
    #5 0x55fc3c164a6b in void testing::internal::HandleExceptionsInMethodIfSupported<testing::Test, void>(testing::Test*, void (testing::Test::*)(), char const*) ../src/gtest/src/gtest.cc:2438
    #6 0x55fc3c109e75 in testing::Test::Run() ../src/gtest/src/gtest.cc:2474
    #7 0x55fc3c10c54e in testing::TestInfo::Run() ../src/gtest/src/gtest.cc:2656
    #8 0x55fc3c10ecdc in testing::TestCase::Run() ../src/gtest/src/gtest.cc:2774
    #9 0x55fc3c12a6b6 in testing::internal::UnitTestImpl::RunAllTests() ../src/gtest/src/gtest.cc:4649
    #10 0x55fc3c17cd76 in bool testing::internal::HandleSehExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) ../src/gtest/src/gtest.cc:2402
    #11 0x55fc3c168443 in bool testing::internal::HandleExceptionsInMethodIfSupported<testing::internal::UnitTestImpl, bool>(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*) ../src/gtest/src/gtest.cc:2438
    #12 0x55fc3c121cd8 in testing::UnitTest::Run() ../src/gtest/src/gtest.cc:4257
    #13 0x55fc3c1a1b91 in RUN_ALL_TESTS() ../src/gtest/include/gtest/gtest.h:2233
    #14 0x55fc3c1a1a51 in main ../src/gtest/src/gtest_main.cc:37
    #15 0x7fd224759bba in __libc_start_main ../csu/libc-start.c:308
    #16 0x55fc3c0e5dc9 in _start (/home/daenzer/src/mesa-git/mesa/build-amd64-sanitize/src/util/tests/fast_idiv_by_const/fast_idiv_by_const_test+0x96dc9)

v2:
* Use two casts instead of changing the argument type (Jason Ekstrand)

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2019-10-24 16:21:01 +02:00
..
sha1
tests util: Use uint64_t for shifting left in sign_extend and strunc 2019-10-24 16:21:01 +02:00
xmlpool vulkan: add vk_x11_strict_image_count option 2019-09-15 15:37:02 +03:00
00-mesa-defaults.conf drirc: enable vk_x11_override_min_image_count for DOOM 2019-10-09 08:38:38 +02:00
Android.mk android: fix linking issues with liblog 2019-09-07 13:16:29 +03:00
anon_file.c util: use _WIN32 instead of WIN32 2019-10-10 16:33:04 -07:00
anon_file.h util/anon_file: const string param 2019-08-08 22:02:54 +01:00
bigmath.h
bitscan.c util: only allow _BitScanReverse64 on 64-bit cpus 2019-09-02 12:45:45 +00:00
bitscan.h util: only allow _BitScanReverse64 on 64-bit cpus 2019-09-02 12:45:45 +00:00
bitset.h util/bitset: fix bitset range mask calculations. 2019-05-03 15:23:04 +10:00
bitset_test.cpp util/tests: add basic unit tests for bitset 2019-05-03 15:23:04 +10:00
blob.c Move blob from compiler/ to util/ 2019-09-19 19:56:22 +00:00
blob.h Move blob from compiler/ to util/ 2019-09-19 19:56:22 +00:00
blob_test.c Move blob from compiler/ to util/ 2019-09-19 19:56:22 +00:00
build_id.c
build_id.h util: add missing include to build_id.h 2019-05-20 10:24:23 +10:00
crc32.c
crc32.h
dag.c util: Add a DAG datastructure. 2019-03-11 13:13:52 -07:00
dag.h util: Add a DAG datastructure. 2019-03-11 13:13:52 -07:00
debug.c win32: unify strcasecmp definitions 2019-08-15 20:23:44 +02:00
debug.h
detect_os.h util: introduce detect_os.h 2019-08-02 18:38:52 +01:00
disk_cache.c util/disk_cache: finish all queue jobs in destroy instead of killing them 2019-10-23 20:22:50 -04:00
disk_cache.h
double.c util: add fp64 -> fp32 conversion support for RTNE and RTZ rounding modes 2019-09-17 23:39:18 +03:00
double.h util: add fp64 -> fp32 conversion support for RTNE and RTZ rounding modes 2019-09-17 23:39:18 +03:00
fast_idiv_by_const.c util: Use uint64_t for shifting left in sign_extend and strunc 2019-10-24 16:21:01 +02:00
fast_idiv_by_const.h
fast_urem_by_const.h util: Add a helper for faster remainders 2019-05-31 19:14:27 +02:00
format_r11g11b10f.h
format_rgb9e5.h
format_srgb.h
format_srgb.py
futex.h util/futex: fix dangling pointer use 2019-06-12 17:27:44 +01:00
half_float.c util: add float to float16 conversions with RTZ and RTNE 2019-09-17 23:39:18 +03:00
half_float.h util: add float to float16 conversions with RTZ and RTNE 2019-09-17 23:39:18 +03:00
hash_table.c util/hash_table: Fix hashing in clears on 32-bit 2019-08-08 07:42:52 +02:00
hash_table.h i965: Fix INTEL_DEBUG=bat 2019-06-12 15:57:16 -07:00
list.h list: add some iterator debug 2019-05-30 22:11:26 +00:00
macros.h util: Add unreachable() definition for clang compiler. 2019-08-30 05:50:21 +00:00
Makefile.sources Move blob from compiler/ to util/ 2019-09-19 19:56:22 +00:00
merge_driinfo.py radeonsi: add si_debug_options for convenient adding/removing of options 2019-04-25 12:31:02 +02:00
mesa-sha1.c
mesa-sha1.h
mesa-sha1_test.c
meson.build meson/util: Don't run string_buffer tests on mingw 2019-10-10 16:33:04 -07:00
os_file.c util/os_file: fix double-close() 2019-09-04 00:11:51 +01:00
os_file.h util: add os_file_create_unique() 2019-06-28 23:37:49 +01:00
os_memory.h util/os_memory: use detect_os.h to uncouple it from gallium 2019-08-02 18:38:52 +01:00
os_memory_aligned.h util/os_memory: use detect_os.h to uncouple it from gallium 2019-08-02 18:38:52 +01:00
os_memory_debug.h util/os_memory: use detect_os.h to uncouple it from gallium 2019-08-02 18:38:52 +01:00
os_memory_stdc.h util/os_memory: use detect_os.h to uncouple it from gallium 2019-08-02 18:38:52 +01:00
os_misc.c util: android logging support 2019-09-06 00:45:11 +00:00
os_misc.h util: os_misc: drop p_compiler.h include 2019-08-09 22:59:43 +03:00
os_time.c util/os_time: use detect_os.h to uncouple from gallium 2019-08-02 18:38:52 +01:00
os_time.h
ralloc.c util/ralloc: Add helpers for growing zero-initialized memory 2019-05-14 12:30:22 -05:00
ralloc.h util/ralloc: Add helpers for growing zero-initialized memory 2019-05-14 12:30:22 -05:00
rand_xor.c
rand_xor.h
rb_tree.c
rb_tree.h util/rb_tree: Stop relying on &iter->field != NULL 2019-09-26 20:36:41 +00:00
rb_tree_test.c util/rb_tree: Also test _safe iterators 2019-09-26 20:36:41 +00:00
register_allocate.c util/ra: Add a getter for a node class 2019-07-25 06:14:12 -07:00
register_allocate.h util/ra: Add a getter for a node class 2019-07-25 06:14:12 -07:00
rgtc.c
rgtc.h
roundeven_test.c
rounding.h util: do not assume MSVC implies SSE 2019-09-02 12:45:45 +00:00
SConscript
set.c util/set: Assert that keys are not reserved pointers 2019-06-06 00:27:53 +00:00
set.h util/set: Use fast modulo computation 2019-05-31 19:14:30 +02:00
simple_list.h
simple_mtx.h tree-wide: replace MAYBE_UNUSED with ASSERTED 2019-07-31 09:41:05 +01:00
slab.c Change a few frequented uses of DEBUG to !NDEBUG 2019-05-29 21:13:35 -04:00
slab.h
softfloat.c util: add softfloat functions to operate with doubles and floats 2019-09-17 23:39:18 +03:00
softfloat.h util: add softfloat functions to operate with doubles and floats 2019-09-17 23:39:18 +03:00
string_buffer.c util: use standard name for vsnprintf() 2019-07-19 22:39:38 +01:00
string_buffer.h
strndup.h
strtod.c
strtod.h
texcompress_rgtc_tmp.h
timespec.h util/timespec: use unsigned 64 bit integers for nsec values 2019-08-22 09:35:57 +02:00
u_atomic.c
u_atomic.h util/u_atomic: fix return type of p_atomic_{inc,dec}_return() and p_atomic_{cmp,}xchg() 2019-10-16 19:41:47 +01:00
u_atomic_test.c
u_cpu_detect.c util: simplify BSD includes 2019-10-09 12:55:15 -07:00
u_cpu_detect.h util: drop final reference to p_compiler.h 2019-08-09 22:59:43 +03:00
u_debug.c util: drop final reference to p_compiler.h 2019-08-09 22:59:43 +03:00
u_debug.h util: drop final reference to p_compiler.h 2019-08-09 22:59:43 +03:00
u_drm.h util: Add a drm_find_modifier helper 2019-03-14 22:41:08 +00:00
u_dynarray.h u_dynarray: turn util_dynarray_{grow, resize} into element-oriented macros 2019-06-12 18:30:25 -04:00
u_endian.h
u_math.c util: u_math: drop p_compiler.h include 2019-08-09 22:59:43 +03:00
u_math.h util: include u_endian.h in u_math.h 2019-09-06 19:52:50 +00:00
u_memory.h
u_process.c util: fix to detect NetBSD properly 2019-10-09 13:01:17 -07:00
u_process.h
u_queue.c util/u_queue: skip util_queue_finish if num_threads is 0 2019-10-23 21:11:17 -04:00
u_queue.h util/u_queue: track job size and limit the size of queue growth 2019-09-19 15:03:27 +10:00
u_string.h util: Define strchrnul on macOS. 2019-08-31 13:26:10 -07:00
u_thread.h util: Solaris has linux-style pthread_setname_np 2019-10-16 13:45:57 +01:00
u_vector.c
u_vector.h util: fix no-op macro (bad number of arguments) 2019-07-24 09:13:58 +01:00
vma.c
vma.h
xmlconfig.c util/xmlconfig: include strndup.h for windows 2019-10-10 16:33:04 -07:00
xmlconfig.h driconfig: add a new engine name/version parameter 2019-09-15 15:37:02 +03:00
xmlpool.h driinfo: add DTD to allow the xml to be validated 2019-02-26 12:48:28 +00:00