Subject: bug#25364: etags malloc problems

From: Eli Zaretskii <[email-masked]>
Date: Thu, 05 Jan 2017 17:36:19 +0200

> Date: Thu, 05 Jan 2017 03:07:13 +0000
> From: <[email-masked]>
> 
> clang-3.9  -g -pipe -Wall -O1 -fsanitize=address -fno-omit-frame-pointer   -MD  -MF.depend.etags.o -MTetags.o -std=gnu99 -fstack-protector-strong    -Qunused-arguments  -c etags.c -o etags.o
> etags.c:6367:25: warning: assigning to 'unsigned char *' from 'char [256]'
>       converts between pointers to integer types with different sign
>       [-Wpointer-sign]
>       patbuf->translate = lc_trans;     /* translation table to fold case  */
>                         ^ ~~~~~~~~
> 1 warning generated.

This warning is a harmless nuisance, AFAIU.

> ==5176==ERROR: LeakSanitizer: detected memory leaks
> 
> Direct leak of 120 byte(s) in 1 object(s) allocated from:
>     #0 0x4cba68 in __interceptor_malloc (/tmp/etags/etags+0x4cba68)
>     #1 0x5043f8 in xmalloc /tmp/etags/etags.c:7238:18
>     #2 0x5036c5 in main /tmp/etags/etags.c:1097:15
>     #3 0x7fb31bc332b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
> 
> Direct leak of 40 byte(s) in 1 object(s) allocated from:
>     #0 0x4cba68 in __interceptor_malloc (/tmp/etags/etags+0x4cba68)
>     #1 0x5043f8 in xmalloc /tmp/etags/etags.c:7238:18
>     #2 0x5036b8 in main /tmp/etags/etags.c:1091:20
>     #3 0x7fb31bc332b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
> 
> Direct leak of 24 byte(s) in 1 object(s) allocated from:
>     #0 0x4cba68 in __interceptor_malloc (/tmp/etags/etags+0x4cba68)
>     #1 0x5043f8 in xmalloc /tmp/etags/etags.c:7238:18
>     #2 0x50447c in concat /tmp/etags/etags.c:6958:18
>     #3 0x503706 in main /tmp/etags/etags.c:1109:15
>     #4 0x7fb31bc332b0 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x202b0)
> 
> SUMMARY: AddressSanitizer: 184 byte(s) leaked in 3 allocation(s).
> 
> the attached patch is what i used to make etags.c compile.

I'm not sure I understand why all those patches are needed.  Is that
just to shut up the above warning?  If there were other problems
during compilation, please show the warning/error messages.

Also, it looks like you are using some old version of the Emacs
sources, because neither Emacs 25.1, the latest released version, nor
the current master branch match the line numbers reported by the
compiler.  Could you try the latest version of the sources, and see if
the problems you found are still there?

Thanks.