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:916:20 #141

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

==74616==WARNING: AddressSanitizer failed to allocate 0x51fc66500400000 bytes
==74616==AddressSanitizer's allocator is terminating the process instead of returning 0
==74616==If you don't like this behavior set allocator_may_return_null=1
==74616==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 0x5c2e95 in ReadNextCell /home/seviezhou/matio/src/mat5.c:916:20
    #7 0x5bb922 in Mat_VarReadNextInfo5 /home/seviezhou/matio/src/mat5.c:5234:27
    #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 0x7f1d60b4bb96 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-ReadNextCell-mat5-916.zip

tbeu commented 3 years ago

I do not consider this as severe issue.

If you don't like this behavior set allocator_may_return_null=1