tbeu / matio

MATLAB MAT File I/O Library
https://matio.sourceforge.io
BSD 2-Clause "Simplified" License
330 stars 97 forks source link

A malloc size error in mat5.c:1649:24 #144

Closed seviezhou closed 3 years ago

seviezhou commented 3 years ago

System info

Ubuntu X64, gcc (Ubuntu 5.5.0-12ubuntu1), matdump (latest master 7a1831)

Command line

./tools/matdump @@

AddressSanitizer output

==9701==WARNING: AddressSanitizer failed to allocate 0xf00f0000f10 bytes
==9701==AddressSanitizer's allocator is terminating the process instead of returning 0
==9701==If you don't like this behavior set allocator_may_return_null=1
==9701==AddressSanitizer CHECK failed: /build/llvm-toolchain-6.0-QjOn7h/llvm-toolchain-6.0-6.0/projects/compiler-rt/lib/sanitizer_common/sanitizer_allocator.cc:225 "((0)) != (0)" (0x0, 0x0)
    #0 0x4e37f5 in __asan::AsanCheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) (/home/seviezhou/matio/tools/matdump+0x4e37f5)
    #1 0x5010a5 in __sanitizer::CheckFailed(char const*, int, char const*, unsigned long long, unsigned long long) (/home/seviezhou/matio/tools/matdump+0x5010a5)
    #2 0x4e9be6 in __sanitizer::ReportAllocatorCannotReturnNull() (/home/seviezhou/matio/tools/matdump+0x4e9be6)
    #3 0x4e9c26 in __sanitizer::ReturnNullOrDieOnFailure::OnBadRequest() (/home/seviezhou/matio/tools/matdump+0x4e9c26)
    #4 0x425809 in __asan::asan_calloc(unsigned long, unsigned long, __sanitizer::BufferedStackTrace*) (/home/seviezhou/matio/tools/matdump+0x425809)
    #5 0x4da8a2 in calloc (/home/seviezhou/matio/tools/matdump+0x4da8a2)
    #6 0x5bdd11 in ReadNextStructField /home/seviezhou/matio/src/mat5.c:1649:24
    #7 0x5ba362 in Mat_VarReadNextInfo5 /home/seviezhou/matio/src/mat5.c:5349:23
    #8 0x522ae1 in Mat_VarReadNextInfo /home/seviezhou/matio/src/mat.c:2418:22
    #9 0x515e15 in main /home/seviezhou/matio/tools/matdump.c:944:31
    #10 0x7f4b3f6d6b96 in __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310
    #11 0x41a7e9 in _start (/home/seviezhou/matio/tools/matdump+0x41a7e9)

POC

malloc-size-error-ReadNextStructField-mat5-1649.zip