Got a core dump in running the testsuite for "literal too long" (current svn version).
Output when running directly:
prog.cob: 9: Error: Invalid literal: ' ...'
prog.cob: 9: Error: Literal length exceeds 8191 characters
Segmentation Fault (core dumped)
The following backtrace was produced by:
./configure --enable-debugecho backtrace > backtrace.cmd gdb /tmp/gnu-cobol-2.0/cobc/.libs/cobc /tmp/gnu-cobol-2.0/tests/testsuite.dir/129/core -batch -x backtrace.cmdCore was generated by `/tmp/gnu-cobol-2.0/cobc/.libs/cobc -fsyntax-only -debug -Wall -std=d'.
Program terminated with signal 11, Segmentation fault.
[New process 82904 ]
#0 0xfffffd7fff1f1418 in realfree () from /lib/64/libc.so.1
(gdb) backtrace
#0 0xfffffd7fff1f1418 in realfree () from /lib/64/libc.so.1
#1 0xfffffd7fff1f1a5c in _free_unlocked () from /lib/64/libc.so.1
#2 0xfffffd7fff1f19b9 in free () from /lib/64/libc.so.1
#3 0x0000000000415e1c in cobc_free (mptr=0x4c64f0) at cobc.c:666
#4 0x0000000000415a49 in cobc_free_mem () at cobc.c:498
#5 0x00000000004176da in cobc_clean_up (status=1) at cobc.c:1454
#6 0x00000000004177fe in cobc_sig_handler (sig=11) at cobc.c:1516
#7 0xfffffd7fff252616 in __sighndlr () from /lib/64/libc.so.1
#8 0xfffffd7fff245de6 in call_user_handler () from /lib/64/libc.so.1
#9 0xfffffd7fff246007 in sigacthandler () from /lib/64/libc.so.1
#10 0xffffffffffffffff in ?? ()
#11 0x000000000000000b in ?? ()
#12 0x0000000000000000 in ?? ()
Analysis:
the error occurs in
scanner.l does the following during initialisation:
and the following when parsing the literals:
cobc. (
cobc_realloc) isThis works fine in general but does not work when the pointer was allocated via
cobc_mallocas this stores all it's allocation in a linked listcobc_mainmem_basewhich is defined in cobc.h as:ToDo:
*memptrandmemlen, plus the referencing item's*nextRelated
Patches:
#23Last edit: Simon Sobisch 2016-01-26
The above is false information (which comes from only glancing on the code):
cobc_mallocandcobc_reallocbelong together and have nothing to do withcobc_mainmem_base, neither hasplexbuff.But the direction is likely correct, at least I assume some storage that was allocated with
cobc_main_mallocwas not reallocated withcobc_main_realloc/ or not passed tocobc_main_free(which all work oncobc_mainmem_base).Further checks needed...
Further checks done:
cobc_main_mallocdoes the internal allocationcobc_mem_structare correct when calling cobc_freecb_extension_listwhere it's very unlikely that the memory got a call to free in other places-fsyntax-only(which is done by the testsuite), without this flag (= more allocations) everything is fine !?!Attached is a debugging version of cobc.[ch] leading to the output of testsuite.log which is attached, too, both with and without
-fsyntax-only.I won't do any further checks on this item for now and leave further checks and the fix to someone else, otherwise this bug stays here as a known bug...
I've tried to run valgrind but it does not build on this machine (neither latest release not the solaris-port).
So this is the output from a different machine...
From
valgrind --tool=exp-sgcheck --read-var-info=yesYAY, no stack problems found.
From
valgrind --tool=memcheck --read-var-info=yes --track-origins=yes --leak-check=fullI'll have to check this later.
The bug is fixed with [r753] and [r754]. It occured if literal size > pplexsize (256/512/...) or > literal_length.
... the test case is broken again...
Fixed with [r1036].