[test-suite] r371219 - [MiBench] consumer-typeset: z31: GetMemory(): don't apply offset to nullptr, it's UB
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 6 09:02:43 PDT 2019
Author: lebedevri
Date: Fri Sep 6 09:02:43 2019
New Revision: 371219
URL: http://llvm.org/viewvc/llvm-project?rev=371219&view=rev
Log:
[MiBench] consumer-typeset: z31: GetMemory(): don't apply offset to nullptr, it's UB
Caught by D67122
/repositories/llvm-test-suite/MultiSource/Benchmarks/MiBench/consumer-typeset/z31.c:352:8: runtime error: applying non-zero offset 96 to null pointer
#0 0x2e682c in GetMemory (/builddirs/build-test-suite-new/MultiSource/Benchmarks/MiBench/consumer-typeset/consumer-typeset+0x2e682c)
#1 0x258c4b in InitFiles (/builddirs/build-test-suite-new/MultiSource/Benchmarks/MiBench/consumer-typeset/consumer-typeset+0x258c4b)
#2 0x24d34e in main (/builddirs/build-test-suite-new/MultiSource/Benchmarks/MiBench/consumer-typeset/consumer-typeset+0x24d34e)
#3 0x7fe3fb2ac09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
#4 0x22e029 in _start (/builddirs/build-test-suite-new/MultiSource/Benchmarks/MiBench/consumer-typeset/consumer-typeset+0x22e029)
After that if() the code expects to have enough memory,
so the branch should be unconditionally taken if next_free == nullptr,
Modified:
test-suite/trunk/MultiSource/Benchmarks/MiBench/consumer-typeset/z31.c
Modified: test-suite/trunk/MultiSource/Benchmarks/MiBench/consumer-typeset/z31.c
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/MiBench/consumer-typeset/z31.c?rev=371219&r1=371218&r2=371219&view=diff
==============================================================================
--- test-suite/trunk/MultiSource/Benchmarks/MiBench/consumer-typeset/z31.c (original)
+++ test-suite/trunk/MultiSource/Benchmarks/MiBench/consumer-typeset/z31.c Fri Sep 6 09:02:43 2019
@@ -349,7 +349,7 @@ OBJECT GetMemory(int siz, FILE_POS *pos)
debug1(DMA, DDD, "GetMemory( %d )", siz);
/* get memory from operating system, if not enough left here */
- if( &next_free[siz] > top_free )
+ if( !next_free || &next_free[siz] > top_free )
{
#if DEBUG_ON
DebugRegisterUsage(MEM_OBJECTS, 1, MEM_CHUNK * sizeof(ALIGN));
More information about the llvm-commits
mailing list