calc
calc copied to clipboard
Bug: realloc of globalnames by addstr results in heap-use-after-free
When compiling calc with clang on macOS AND with the following in Makefile.local:
CFLAGS+= -fsanitize=address
LDFLAGS+= -fsanitize=address
Running 'make chk' results calc reporting:
AddressSanitizer: heap-use-after-free
See issue.txt for details.
The problem here is that when addglobal() (see addglobal symbol.c:122):
sp->g_name = addstr(&globalnames, name);
and then addstr() does a realloc (see addstr str.c:115):
list = (char *)realloc(hp->h_list, newsize + 1);
pointers into that global block become BOGUS. Normally symbols are located within globalnames by an offset, which is correct. Something in calc is doing the wrong thing and is retaining a pointer into globalnames when it should use an offset instead.
Realloc is allowed to move the memory block, so global symbol lookup should use an OFFSET into globalnames, NOT pointers!
This bug is triggered when lots of global symbols are defined. This happens, for example, when the cal/regress.cal code is run. Because of the extensive script use, enough global symbols are defined that the initial global symbol block is filled and realloc() can move it.
Triggering this bug is highly dependent on the libc allocator, so your kilometer-age may vary. :-)
Nevertheless, the issue of realloc in calc should be carefully examined when it goes to larger blocks such as that for globalnames.
While this bug was first observed in v2.14.0.14, it appears this bug goes way back to pre-1999. Thanks to clang, we have identified this flaw and intend to correct it.
Comments, and bug fix patches are welcome!
FYI: The follow patch does NOT fix this problem .. it only "kicks the can down the road" far enough for calc/regeess.cal (i.e., make chk) to not trigger the reallocation of globalnames bug:
diff --git a/str.c b/str.c index 8b3bb81..1a098ff 100644 --- a/str.c +++ b/str.c @@ -42,7 +42,7 @@
#define STR_TABLECHUNK 100 /* how often to reallocate string table / -#define STR_CHUNK (1<<11) / size of string storage allocation / +#define STR_CHUNK (1<<12) / size of string storage allocation / #define OCTET_VALUES 256 / number of different values in a OCTET / #define STR_UNIQUE (1<<7) / size of string to allocate separately */
We will likely increate the STR_CHUNK size away in a future release. Nevertheless this bug needs to be fixed.
FYI: We are using the following lines in Makefile.local to invoke clang AddressSanitizer on macOS 12.1:
CFLAGS+= -fsanitize=address -fno-omit-frame-pointer LDFLAGS+= -fsanitize=address -fno-omit-frame-pointer CALC_ENV+= ASAN_OPTIONS=detect_stack_use_after_return=1
You might want to try some of the other sanitizers too. For example: -fsanitize=undefined and -fsanitize=memory.
We found that gcc version 4.8.5 with libasan-4.8.5-4, only this was supported:
-fsanitize=address -fno-omit-frame-pointer
On macOS 12.1 with clang version 13.0.0 (clang-1300.0.29.30), only this was supported:
-fsanitize=address -fno-omit-frame-pointer -fsanitize=undefined
We didn't find (yet) an instance where -fsanitize=memory was supported.
Thanks for the suggestions: We added some to the Makefile.local at the top of the master branch. More ideas are welcome.
We recommend debugging the realloc problem with the following patch:
The issue can be triggered faster by lowering the value of both STR_TABLECHUNK and STR_CHUNK
You may not be able to run memory at the same time as some of the others. I haven't used it in a while (perhaps almost a year...)
Thanks
When the following patch:
is applied to the top of the calc master bench (for what will be calc version 2.14.1.4)
under macOS 13.2.1 using clang version 14.0.0 (clang-1400.0.29.202),
the make chk crashes with a AddressSanitizer: heap-use-after-free error!
The output of:
make check > debug.out.txt 2>&1
is attached here:
STATUS UPDATE for RHEL 9.2 calc v2.15.0.1
Under RHEL 9.2 with calc v2.15.0.1 source with clang version 15.0.7 (Red Hat 15.0.7-2.el9), adding these lines to Makefile.local:
CFLAGS+= -fsanitize=address
LDFLAGS+= -fsanitize=address
doing a make clobber all chk yields:
=================================================================
==755953==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 360 byte(s) in 15 object(s) allocated from:
#0 0x7f25f58b4a07 in __interceptor_malloc (/lib64/libasan.so.6+0xb4a07)
#1 0x7f25f54977cd in comalloc /usr/local/src/bin/calc/commath.c:768
Direct leak of 156 byte(s) in 4 object(s) allocated from:
#0 0x7f25f58b4a07 in __interceptor_malloc (/lib64/libasan.so.6+0xb4a07)
#1 0x7f25f5598ade in alloc /usr/local/src/bin/calc/zmath.c:242
Direct leak of 72 byte(s) in 3 object(s) allocated from:
#0 0x7f25f58b4a07 in __interceptor_malloc (/lib64/libasan.so.6+0xb4a07)
#1 0x7f25f54977cd in comalloc /usr/local/src/bin/calc/commath.c:768
#2 0x7f25f5688c1f (/usr/local/src/bin/calc/libcalc.so.2.15.0.1+0x288c1f)
SUMMARY: AddressSanitizer: 588 byte(s) leaked in 22 allocation(s).
Under RHEL 9.2 with calc v2.15.0.1 source with clang version 15.0.7 (Red Hat 15.0.7-2.el9), adding these lines to Makefile.local:
CFLAGS+= -fsanitize=address -fno-omit-frame-pointer
LDFLAGS+= -fsanitize=address -fno-omit-frame-pointer
doing a make clobber all chk yields:
Direct leak of 96 byte(s) in 4 object(s) allocated from:
#0 0x7fc197cb4a07 in __interceptor_malloc (/lib64/libasan.so.6+0xb4a07)
#1 0x7fc19789803d in comalloc /usr/local/src/bin/calc/commath.c:768
#2 0x7fc19788fb43 in c_ln /usr/local/src/bin/calc/comfunc.c:514
#3 0x7fc1978d9044 in f_logn /usr/local/src/bin/calc/func.c:2549
#4 0x7fc1978eeb1f in builtinfunc /usr/local/src/bin/calc/func.c:13401
#5 0x7fc197914b31 in o_call /usr/local/src/bin/calc/opcodes.c:2725
#6 0x7fc197920157 in calculate /usr/local/src/bin/calc/opcodes.c:4179
#7 0x7fc197920157 in calculate /usr/local/src/bin/calc/opcodes.c:4179
#8 0x7fc197887e12 in evaluate /usr/local/src/bin/calc/codegen.c:300
#9 0x7fc197888080 in getcommands /usr/local/src/bin/calc/codegen.c:230
#10 0x7fc19788870e in getcommands /usr/local/src/bin/calc/codegen.c:187
#11 0x404d04 in main /usr/local/src/bin/calc/calc.c:669
#12 0x7fc19743feaf in __libc_start_call_main (/lib64/libc.so.6+0x3feaf)
Direct leak of 72 byte(s) in 3 object(s) allocated from:
#0 0x7fc197cb4a07 in __interceptor_malloc (/lib64/libasan.so.6+0xb4a07)
#1 0x7fc19789803d in comalloc /usr/local/src/bin/calc/commath.c:768
#2 0x7fc19788fb43 in c_ln /usr/local/src/bin/calc/comfunc.c:514
#3 0x7fc1978d8ca6 in f_logn /usr/local/src/bin/calc/func.c:2472
#4 0x7fc1978eeb1f in builtinfunc /usr/local/src/bin/calc/func.c:13401
#5 0x7fc197914b31 in o_call /usr/local/src/bin/calc/opcodes.c:2725
#6 0x7fc197920157 in calculate /usr/local/src/bin/calc/opcodes.c:4179
#7 0x7fc197920157 in calculate /usr/local/src/bin/calc/opcodes.c:4179
#8 0x7fc197887e12 in evaluate /usr/local/src/bin/calc/codegen.c:300
#9 0x7fc197888080 in getcommands /usr/local/src/bin/calc/codegen.c:230
#10 0x7fc19788870e in getcommands /usr/local/src/bin/calc/codegen.c:187
#11 0x404d04 in main /usr/local/src/bin/calc/calc.c:669
#12 0x7fc19743feaf in __libc_start_call_main (/lib64/libc.so.6+0x3feaf)
Direct leak of 48 byte(s) in 2 object(s) allocated from:
#0 0x7fc197cb4a07 in __interceptor_malloc (/lib64/libasan.so.6+0xb4a07)
#1 0x7fc19789803d in comalloc /usr/local/src/bin/calc/commath.c:768
#2 0x7fc19788fb43 in c_ln /usr/local/src/bin/calc/comfunc.c:514
#3 0x7fc1978d8a08 in f_logn /usr/local/src/bin/calc/func.c:2492
#4 0x7fc1978eeb1f in builtinfunc /usr/local/src/bin/calc/func.c:13401
#5 0x7fc197914b31 in o_call /usr/local/src/bin/calc/opcodes.c:2725
#6 0x7fc197920157 in calculate /usr/local/src/bin/calc/opcodes.c:4179
#7 0x7fc197920157 in calculate /usr/local/src/bin/calc/opcodes.c:4179
#8 0x7fc197887e12 in evaluate /usr/local/src/bin/calc/codegen.c:300
#9 0x7fc197888080 in getcommands /usr/local/src/bin/calc/codegen.c:230
#10 0x7fc19788870e in getcommands /usr/local/src/bin/calc/codegen.c:187
#11 0x404d04 in main /usr/local/src/bin/calc/calc.c:669
#12 0x7fc19743feaf in __libc_start_call_main (/lib64/libc.so.6+0x3feaf)
Direct leak of 40 byte(s) in 1 object(s) allocated from:
#0 0x7fc197cb4a07 in __interceptor_malloc (/lib64/libasan.so.6+0xb4a07)
#1 0x7fc1979a1a1e in alloc /usr/local/src/bin/calc/zmath.c:242
#2 0x7fc1979a4194 in zdiv /usr/local/src/bin/calc/zmath.c:1008
#3 0x7fc1979a4c77 in zmod /usr/local/src/bin/calc/zmath.c:1069
#4 0x7fc1979ace4e in zsquaremod /usr/local/src/bin/calc/zmod.c:122
#5 0x7fc1979d5975 in zsrandom1 /usr/local/src/bin/calc/zrandom.c:2333
#6 0x7fc1978bb1f5 in f_srandom /usr/local/src/bin/calc/func.c:1320
#7 0x7fc1978eeb1f in builtinfunc /usr/local/src/bin/calc/func.c:13401
#8 0x7fc197914b31 in o_call /usr/local/src/bin/calc/opcodes.c:2725
#9 0x7fc197920157 in calculate /usr/local/src/bin/calc/opcodes.c:4179
#10 0x7fc197920157 in calculate /usr/local/src/bin/calc/opcodes.c:4179
#11 0x7fc197887e12 in evaluate /usr/local/src/bin/calc/codegen.c:300
#12 0x7fc197888080 in getcommands /usr/local/src/bin/calc/codegen.c:230
#13 0x7fc19788870e in getcommands /usr/local/src/bin/calc/codegen.c:187
#14 0x404d04 in main /usr/local/src/bin/calc/calc.c:669
#15 0x7fc19743feaf in __libc_start_call_main (/lib64/libc.so.6+0x3feaf)
Direct leak of 40 byte(s) in 1 object(s) allocated from:
#0 0x7fc197cb4a07 in __interceptor_malloc (/lib64/libasan.so.6+0xb4a07)
#1 0x7fc1979a1a1e in alloc /usr/local/src/bin/calc/zmath.c:242
#2 0x7fc1979a4194 in zdiv /usr/local/src/bin/calc/zmath.c:1008
#3 0x7fc1979a4c77 in zmod /usr/local/src/bin/calc/zmath.c:1069
#4 0x7fc1979ace4e in zsquaremod /usr/local/src/bin/calc/zmod.c:122
#5 0x7fc1979d7b24 in zrandom /usr/local/src/bin/calc/zrandom.c:2920
#6 0x7fc1978be7cc in f_random /usr/local/src/bin/calc/func.c:1207
#7 0x7fc1978eecd8 in builtinfunc /usr/local/src/bin/calc/func.c:13420
#8 0x7fc197914b31 in o_call /usr/local/src/bin/calc/opcodes.c:2725
#9 0x7fc197920157 in calculate /usr/local/src/bin/calc/opcodes.c:4179
#10 0x7fc197920157 in calculate /usr/local/src/bin/calc/opcodes.c:4179
#11 0x7fc197887e12 in evaluate /usr/local/src/bin/calc/codegen.c:300
#12 0x7fc197888080 in getcommands /usr/local/src/bin/calc/codegen.c:230
#13 0x7fc19788870e in getcommands /usr/local/src/bin/calc/codegen.c:187
#14 0x404d04 in main /usr/local/src/bin/calc/calc.c:669
#15 0x7fc19743feaf in __libc_start_call_main (/lib64/libc.so.6+0x3feaf)
Direct leak of 40 byte(s) in 1 object(s) allocated from:
#0 0x7fc197cb4a07 in __interceptor_malloc (/lib64/libasan.so.6+0xb4a07)
#1 0x7fc1979a1a1e in alloc /usr/local/src/bin/calc/zmath.c:242
#2 0x7fc1979a4194 in zdiv /usr/local/src/bin/calc/zmath.c:1008
#3 0x7fc1979a4c77 in zmod /usr/local/src/bin/calc/zmath.c:1069
#4 0x7fc1979ace4e in zsquaremod /usr/local/src/bin/calc/zmod.c:122
#5 0x7fc1979d7b24 in zrandom /usr/local/src/bin/calc/zrandom.c:2920
#6 0x7fc1979d819a in zrandomrange /usr/local/src/bin/calc/zrandom.c:3003
#7 0x7fc1978be7a2 in f_random /usr/local/src/bin/calc/func.c:1230
#8 0x7fc1978eecd8 in builtinfunc /usr/local/src/bin/calc/func.c:13420
#9 0x7fc197914b31 in o_call /usr/local/src/bin/calc/opcodes.c:2725
#10 0x7fc197920157 in calculate /usr/local/src/bin/calc/opcodes.c:4179
#11 0x7fc197920157 in calculate /usr/local/src/bin/calc/opcodes.c:4179
#12 0x7fc197887e12 in evaluate /usr/local/src/bin/calc/codegen.c:300
#13 0x7fc197888080 in getcommands /usr/local/src/bin/calc/codegen.c:230
#14 0x7fc19788870e in getcommands /usr/local/src/bin/calc/codegen.c:187
#15 0x404d04 in main /usr/local/src/bin/calc/calc.c:669
#16 0x7fc19743feaf in __libc_start_call_main (/lib64/libc.so.6+0x3feaf)
Direct leak of 36 byte(s) in 1 object(s) allocated from:
#0 0x7fc197cb4a07 in __interceptor_malloc (/lib64/libasan.so.6+0xb4a07)
#1 0x7fc1979a1a1e in alloc /usr/local/src/bin/calc/zmath.c:242
#2 0x7fc1979a4194 in zdiv /usr/local/src/bin/calc/zmath.c:1008
#3 0x7fc1979a4c77 in zmod /usr/local/src/bin/calc/zmath.c:1069
#4 0x7fc1979ace4e in zsquaremod /usr/local/src/bin/calc/zmod.c:122
#5 0x7fc1979d7b24 in zrandom /usr/local/src/bin/calc/zrandom.c:2920
#6 0x7fc1978be2d7 in f_randombit /usr/local/src/bin/calc/func.c:1256
#7 0x7fc1978eecd8 in builtinfunc /usr/local/src/bin/calc/func.c:13420
#8 0x7fc197914b31 in o_call /usr/local/src/bin/calc/opcodes.c:2725
#9 0x7fc197920157 in calculate /usr/local/src/bin/calc/opcodes.c:4179
#10 0x7fc197920157 in calculate /usr/local/src/bin/calc/opcodes.c:4179
#11 0x7fc197887e12 in evaluate /usr/local/src/bin/calc/codegen.c:300
#12 0x7fc197888080 in getcommands /usr/local/src/bin/calc/codegen.c:230
#13 0x7fc19788870e in getcommands /usr/local/src/bin/calc/codegen.c:187
#14 0x404d04 in main /usr/local/src/bin/calc/calc.c:669
#15 0x7fc19743feaf in __libc_start_call_main (/lib64/libc.so.6+0x3feaf)
Direct leak of 24 byte(s) in 1 object(s) allocated from:
#0 0x7fc197cb4a07 in __interceptor_malloc (/lib64/libasan.so.6+0xb4a07)
#1 0x7fc19789803d in comalloc /usr/local/src/bin/calc/commath.c:768
#2 0x7fc19789e25f in qqtoc /usr/local/src/bin/calc/commath.c:715
#3 0x7fc1978e36a5 in f_acovercos /usr/local/src/bin/calc/func.c:11364
#4 0x7fc1978eeb1f in builtinfunc /usr/local/src/bin/calc/func.c:13401
#5 0x7fc197914b31 in o_call /usr/local/src/bin/calc/opcodes.c:2725
#6 0x7fc197920157 in calculate /usr/local/src/bin/calc/opcodes.c:4179
#7 0x7fc197920157 in calculate /usr/local/src/bin/calc/opcodes.c:4179
#8 0x7fc197887e12 in evaluate /usr/local/src/bin/calc/codegen.c:300
#9 0x7fc197888080 in getcommands /usr/local/src/bin/calc/codegen.c:230
#10 0x7fc19788870e in getcommands /usr/local/src/bin/calc/codegen.c:187
#11 0x404d04 in main /usr/local/src/bin/calc/calc.c:669
#12 0x7fc19743feaf in __libc_start_call_main (/lib64/libc.so.6+0x3feaf)
Direct leak of 24 byte(s) in 1 object(s) allocated from:
#0 0x7fc197cb4a07 in __interceptor_malloc (/lib64/libasan.so.6+0xb4a07)
#1 0x7fc19789803d in comalloc /usr/local/src/bin/calc/commath.c:768
#2 0x7fc19789e25f in qqtoc /usr/local/src/bin/calc/commath.c:715
#3 0x7fc1978e2a65 in f_acrd /usr/local/src/bin/calc/func.c:12348
#4 0x7fc1978eeb1f in builtinfunc /usr/local/src/bin/calc/func.c:13401
#5 0x7fc197914b31 in o_call /usr/local/src/bin/calc/opcodes.c:2725
#6 0x7fc197920157 in calculate /usr/local/src/bin/calc/opcodes.c:4179
#7 0x7fc197920157 in calculate /usr/local/src/bin/calc/opcodes.c:4179
#8 0x7fc197887e12 in evaluate /usr/local/src/bin/calc/codegen.c:300
#9 0x7fc197888080 in getcommands /usr/local/src/bin/calc/codegen.c:230
#10 0x7fc19788870e in getcommands /usr/local/src/bin/calc/codegen.c:187
#11 0x404d04 in main /usr/local/src/bin/calc/calc.c:669
#12 0x7fc19743feaf in __libc_start_call_main (/lib64/libc.so.6+0x3feaf)
Direct leak of 24 byte(s) in 1 object(s) allocated from:
#0 0x7fc197cb4a07 in __interceptor_malloc (/lib64/libasan.so.6+0xb4a07)
#1 0x7fc19789803d in comalloc /usr/local/src/bin/calc/commath.c:768
#2 0x7fc19789e25f in qqtoc /usr/local/src/bin/calc/commath.c:715
#3 0x7fc1978e3395 in f_avercos /usr/local/src/bin/calc/func.c:11224
#4 0x7fc1978eeb1f in builtinfunc /usr/local/src/bin/calc/func.c:13401
#5 0x7fc197914b31 in o_call /usr/local/src/bin/calc/opcodes.c:2725
#6 0x7fc197920157 in calculate /usr/local/src/bin/calc/opcodes.c:4179
#7 0x7fc197920157 in calculate /usr/local/src/bin/calc/opcodes.c:4179
#8 0x7fc197887e12 in evaluate /usr/local/src/bin/calc/codegen.c:300
#9 0x7fc197888080 in getcommands /usr/local/src/bin/calc/codegen.c:230
#10 0x7fc19788870e in getcommands /usr/local/src/bin/calc/codegen.c:187
#11 0x404d04 in main /usr/local/src/bin/calc/calc.c:669
#12 0x7fc19743feaf in __libc_start_call_main (/lib64/libc.so.6+0x3feaf)
Direct leak of 24 byte(s) in 1 object(s) allocated from:
#0 0x7fc197cb4a07 in __interceptor_malloc (/lib64/libasan.so.6+0xb4a07)
#1 0x7fc19789803d in comalloc /usr/local/src/bin/calc/commath.c:768
#2 0x7fc19789e25f in qqtoc /usr/local/src/bin/calc/commath.c:715
#3 0x7fc1978e42e5 in f_ahacovercos /usr/local/src/bin/calc/func.c:11924
#4 0x7fc1978eeb1f in builtinfunc /usr/local/src/bin/calc/func.c:13401
#5 0x7fc197914b31 in o_call /usr/local/src/bin/calc/opcodes.c:2725
#6 0x7fc197920157 in calculate /usr/local/src/bin/calc/opcodes.c:4179
#7 0x7fc197920157 in calculate /usr/local/src/bin/calc/opcodes.c:4179
#8 0x7fc197887e12 in evaluate /usr/local/src/bin/calc/codegen.c:300
#9 0x7fc197888080 in getcommands /usr/local/src/bin/calc/codegen.c:230
#10 0x7fc19788870e in getcommands /usr/local/src/bin/calc/codegen.c:187
#11 0x404d04 in main /usr/local/src/bin/calc/calc.c:669
#12 0x7fc19743feaf in __libc_start_call_main (/lib64/libc.so.6+0x3feaf)
Direct leak of 24 byte(s) in 1 object(s) allocated from:
#0 0x7fc197cb4a07 in __interceptor_malloc (/lib64/libasan.so.6+0xb4a07)
#1 0x7fc19789803d in comalloc /usr/local/src/bin/calc/commath.c:768
#2 0x7fc19789e25f in qqtoc /usr/local/src/bin/calc/commath.c:715
#3 0x7fc1978e3fd5 in f_ahavercos /usr/local/src/bin/calc/func.c:11784
#4 0x7fc1978eeb1f in builtinfunc /usr/local/src/bin/calc/func.c:13401
#5 0x7fc197914b31 in o_call /usr/local/src/bin/calc/opcodes.c:2725
#6 0x7fc197920157 in calculate /usr/local/src/bin/calc/opcodes.c:4179
#7 0x7fc197920157 in calculate /usr/local/src/bin/calc/opcodes.c:4179
#8 0x7fc197887e12 in evaluate /usr/local/src/bin/calc/codegen.c:300
#9 0x7fc197888080 in getcommands /usr/local/src/bin/calc/codegen.c:230
#10 0x7fc19788870e in getcommands /usr/local/src/bin/calc/codegen.c:187
#11 0x404d04 in main /usr/local/src/bin/calc/calc.c:669
#12 0x7fc19743feaf in __libc_start_call_main (/lib64/libc.so.6+0x3feaf)
Direct leak of 24 byte(s) in 1 object(s) allocated from:
#0 0x7fc197cb4a07 in __interceptor_malloc (/lib64/libasan.so.6+0xb4a07)
#1 0x7fc19789803d in comalloc /usr/local/src/bin/calc/commath.c:768
#2 0x7fc19789e25f in qqtoc /usr/local/src/bin/calc/commath.c:715
#3 0x7fc1978e3cc5 in f_ahacoversin /usr/local/src/bin/calc/func.c:11644
#4 0x7fc1978eeb1f in builtinfunc /usr/local/src/bin/calc/func.c:13401
#5 0x7fc197914b31 in o_call /usr/local/src/bin/calc/opcodes.c:2725
#6 0x7fc197920157 in calculate /usr/local/src/bin/calc/opcodes.c:4179
#7 0x7fc197920157 in calculate /usr/local/src/bin/calc/opcodes.c:4179
#8 0x7fc197887e12 in evaluate /usr/local/src/bin/calc/codegen.c:300
#9 0x7fc197888080 in getcommands /usr/local/src/bin/calc/codegen.c:230
#10 0x7fc19788870e in getcommands /usr/local/src/bin/calc/codegen.c:187
#11 0x404d04 in main /usr/local/src/bin/calc/calc.c:669
#12 0x7fc19743feaf in __libc_start_call_main (/lib64/libc.so.6+0x3feaf)
Direct leak of 24 byte(s) in 1 object(s) allocated from:
#0 0x7fc197cb4a07 in __interceptor_malloc (/lib64/libasan.so.6+0xb4a07)
#1 0x7fc19789803d in comalloc /usr/local/src/bin/calc/commath.c:768
#2 0x7fc19789e25f in qqtoc /usr/local/src/bin/calc/commath.c:715
#3 0x7fc1978e39b5 in f_ahaversin /usr/local/src/bin/calc/func.c:11504
#4 0x7fc1978eeb1f in builtinfunc /usr/local/src/bin/calc/func.c:13401
#5 0x7fc197914b31 in o_call /usr/local/src/bin/calc/opcodes.c:2725
#6 0x7fc197920157 in calculate /usr/local/src/bin/calc/opcodes.c:4179
#7 0x7fc197920157 in calculate /usr/local/src/bin/calc/opcodes.c:4179
#8 0x7fc197887e12 in evaluate /usr/local/src/bin/calc/codegen.c:300
#9 0x7fc197888080 in getcommands /usr/local/src/bin/calc/codegen.c:230
#10 0x7fc19788870e in getcommands /usr/local/src/bin/calc/codegen.c:187
#11 0x404d04 in main /usr/local/src/bin/calc/calc.c:669
#12 0x7fc19743feaf in __libc_start_call_main (/lib64/libc.so.6+0x3feaf)
Direct leak of 24 byte(s) in 1 object(s) allocated from:
#0 0x7fc197cb4a07 in __interceptor_malloc (/lib64/libasan.so.6+0xb4a07)
#1 0x7fc19789803d in comalloc /usr/local/src/bin/calc/commath.c:768
#2 0x7fc19789e25f in qqtoc /usr/local/src/bin/calc/commath.c:715
#3 0x7fc1978e3085 in f_acoversin /usr/local/src/bin/calc/func.c:11084
#4 0x7fc1978eeb1f in builtinfunc /usr/local/src/bin/calc/func.c:13401
#5 0x7fc197914b31 in o_call /usr/local/src/bin/calc/opcodes.c:2725
#6 0x7fc197920157 in calculate /usr/local/src/bin/calc/opcodes.c:4179
#7 0x7fc197920157 in calculate /usr/local/src/bin/calc/opcodes.c:4179
#8 0x7fc197887e12 in evaluate /usr/local/src/bin/calc/codegen.c:300
#9 0x7fc197888080 in getcommands /usr/local/src/bin/calc/codegen.c:230
#10 0x7fc19788870e in getcommands /usr/local/src/bin/calc/codegen.c:187
#11 0x404d04 in main /usr/local/src/bin/calc/calc.c:669
#12 0x7fc19743feaf in __libc_start_call_main (/lib64/libc.so.6+0x3feaf)
Direct leak of 24 byte(s) in 1 object(s) allocated from:
#0 0x7fc197cb4a07 in __interceptor_malloc (/lib64/libasan.so.6+0xb4a07)
#1 0x7fc19789803d in comalloc /usr/local/src/bin/calc/commath.c:768
#2 0x7fc19789e25f in qqtoc /usr/local/src/bin/calc/commath.c:715
#3 0x7fc1978e2d75 in f_aversin /usr/local/src/bin/calc/func.c:10944
#4 0x7fc1978eeb1f in builtinfunc /usr/local/src/bin/calc/func.c:13401
#5 0x7fc197914b31 in o_call /usr/local/src/bin/calc/opcodes.c:2725
#6 0x7fc197920157 in calculate /usr/local/src/bin/calc/opcodes.c:4179
#7 0x7fc197920157 in calculate /usr/local/src/bin/calc/opcodes.c:4179
#8 0x7fc197887e12 in evaluate /usr/local/src/bin/calc/codegen.c:300
#9 0x7fc197888080 in getcommands /usr/local/src/bin/calc/codegen.c:230
#10 0x7fc19788870e in getcommands /usr/local/src/bin/calc/codegen.c:187
#11 0x404d04 in main /usr/local/src/bin/calc/calc.c:669
#12 0x7fc19743feaf in __libc_start_call_main (/lib64/libc.so.6+0x3feaf)
SUMMARY: AddressSanitizer: 588 byte(s) leaked in 22 allocation(s).
BTW, side note: for your own sanity, you might want to use https://gist.github.com/ for storing long blobs of text like that for future reference.