bug-gnucobol
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-GnuCOBOL] segfaults during compile


From: folkert
Subject: [Bug-GnuCOBOL] segfaults during compile
Date: Wed, 29 Mar 2017 11:41:00 +0200
User-agent: NeoMutt/20170306 (1.8.0)

Hi,

I'm trying to build some cobol code usng gnu cobol:
        cobc (GnuCOBOL) 2.0.0
        Packaged  Nov 06 2016 22:36:19 UTC
        C version "6.3.0 20170118"

During the compile the compiler segfaults constantly.
I ran it through valgrind and this found the following:

==2205== Invalid read of size 4
==2205==    at 0x170EA9: lookup_pic (codegen.c:904)
==2205==    by 0x171149: lookup_attr (codegen.c:972)
==2205==    by 0x171580: output_attr (codegen.c:1099)
==2205==    by 0x1723C1: output_field (codegen.c:1515)
==2205==    by 0x17517E: output_param (codegen.c:2777)
==2205==    by 0x175BCB: output_funcall (codegen.c:3012)
==2205==    by 0x17CFF0: output_stmt (codegen.c:6107)
==2205==    by 0x17D3C6: output_stmt (codegen.c:6289)
==2205==    by 0x17CC4F: output_stmt (codegen.c:6027)
==2205==    by 0x181044: output_internal_function (codegen.c:7727)
==2205==    by 0x183B88: codegen (codegen.c:8856)
==2205==    by 0x128ABD: process_translate (cobc.c:5200)
==2205==    by 0x12A700: main (cobc.c:6265)
==2205==  Address 0x686dbb8 is 40 bytes inside a block of size 48 free'd
==2205==    at 0x4C2CDDB: free (vg_replace_malloc.c:530)
==2205==    by 0x11E1FC: cobc_free (cobc.c:712)
==2205==    by 0x12A73F: main (cobc.c:6271)
==2205==  Block was alloc'd at
==2205==    at 0x4C2DBC5: calloc (vg_replace_malloc.c:711)
==2205==    by 0x11E5AB: cobc_parse_malloc (cobc.c:861)
==2205==    by 0x170F76: lookup_pic (codegen.c:926)
==2205==    by 0x171149: lookup_attr (codegen.c:972)
==2205==    by 0x171580: output_attr (codegen.c:1099)
==2205==    by 0x1723C1: output_field (codegen.c:1515)
==2205==    by 0x17517E: output_param (codegen.c:2777)
==2205==    by 0x175BCB: output_funcall (codegen.c:3012)
==2205==    by 0x17CFF0: output_stmt (codegen.c:6107)
==2205==    by 0x17D3C6: output_stmt (codegen.c:6289)
==2205==    by 0x17CC4F: output_stmt (codegen.c:6027)
==2205==    by 0x181044: output_internal_function (codegen.c:7727)
==2205==    by 0x183B88: codegen (codegen.c:8856)
==2205==    by 0x128ABD: process_translate (cobc.c:5200)
==2205==    by 0x12A700: main (cobc.c:6265)

So apparently lookup_pic allocates a block of memory which main frees
and then lookup_pic is trying to use it again.

It looks like cobc_parsemem_base is freed but pic_cache in codegen.c is
still referring to the same address which explodes.

Removing the free()-code (as a test) "solves" the problem (albeit with a
memory leak of course).


Folkert van Heusden

-- 
----------------------------------------------------------------------
Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com



reply via email to

[Prev in Thread] Current Thread [Next in Thread]