[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: -fsanitize=memory
- From: "Mike" <tankf33der@...>
- Date: Sat, 23 Nov 2019 20:20:34 +0000
November 22, 2019 3:59 PM, "Roberto Ierusalimschy" <roberto@inf.puc-rio.br> wrote:
>> MemorySanitizer: use-of-uninitialized-value /home/mpech/lua-5.3.5/src/liolib.c:490:58 in read_line
>>
>> Here is the line in question:
>>
>> while (i < LUAL_BUFFERSIZE && (c = l_getc(f)) != EOF && c != '\n')
>>
>> The tool seems to think that c is uninitialized, which is clearly
>> wrong given this line just before the loop:
>>
>> int c = '\0';
>>
>> What am I missing?
>
> Might it be some problem inside macro 'l_getc' (which can be either
> getc or getc_unlocked)?
>
0. My linux distro to play - void and arch, latest glibc 2.30, clang-llvm 9.0
(my distros and platforms park is big, I even have owl linux installed)
1.
create data file mike.txt (two lines):
abc mike
xzy
2.
create test code mike.lua (two lines):
io.input("mike.txt")
print(io.read(1, "l") -- problem here
3.
recompile lua under memory sanitizer, my CC line in Makefile:
CC= clang -g -fsanitize=memory -std=gnu99
4.
any combinations of io.read() below is OK and dont trigger fatal warning of sanitizer:
(1, 1)
(1, 128)
("l", "l") -- L and l are the same meaning here
("l", 1)
("l", "a")
(1, "a")
("a", "a")
5. so problem in io.read(1, "l") combination
6. ok
7. after read_chars() read_line() gets correct FILE stream and cursor position inside g_read()
8. sanitizer quits *immediately* in first touch of l_getc(), no while() loop occurs:
while (i < LUAL_BUFFERSIZE && (c = l_getc(f)) != EOF && c != '\n') {
9. if i replace l_getc (getc_unlocked) to simple getc *NO* error
10. looks like false alarm caused by combination of LLVM and glibc.
(mike)