bug-gnucobol
[Top][All Lists]
Advanced

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

Re: [open-cobol-list] bug report: SIGSEGV in GOBACK


From: Sergey Kashyrin
Subject: Re: [open-cobol-list] bug report: SIGSEGV in GOBACK
Date: Tue, 26 Nov 2013 15:20:55 +0700
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.1.1

Hi,

Can't provide the patch at the moment, but

Find the function cob_sys_copy_file in fileio.c

Replace following 2 lines
    while ((i = read (fd1, fn1, sizeof(fn1))) > 0) {
        if (write (fd2, fn1, (size_t)i) < 0) {
by
    while ((i = read (fd1, file_open_buff, COB_FILE_BUFF)) > 0) {
        if (write (fd2, file_open_buff, (size_t)i) < 0) {

This bug was there from the beginning - using memory block after "free", which on some systems corrupting the heap structure.

Regards,
Sergey


On 11/24/2013 8:48 AM, Matthew Fisher wrote:
This report refers to the gnu-cobol-2.0 branch, checked out today from:

      svn://svn.code.sf.net/p/open-cobol/code/branches/gnu-cobol-2.0

Under certain conditions, a segmentation fault occurs on line 212 of
libcob/common.c.

A minimal test program (compiled with `cobc -xg test.cbl`):

         IDENTIFICATION DIVISION.
         PROGRAM-ID. test.

         DATA DIVISION.
         WORKING-STORAGE SECTION.
         01  CALL-STATUS  BINARY-LONG.

         PROCEDURE DIVISION.
             CALL "C$COPY"
                 USING "test.cbl" "copy.cbl" "S"
                 GIVING CALL-STATUS
             END-CALL

             GOBACK
             .

The output from running the program:

      test.cbl: 14 Attempt to reference unallocated memory (Signal
      SIGSEGV)
      Abnormal termination - File contents may be incorrect

Line 14 is the GOBACK statement. When run in gdb, with a breakpoint
set in cob_exit_common, it can be seen that the seg fault occurs on
the free statement in line 212 of libcob/common.c:

      if (cobglobptr->cob_term_buff) {
          free (cobglobptr->cob_term_buff);
      }


------------------------------------------------------------------------------
Shape the Mobile Experience: Free Subscription
Software experts and developers: Be at the forefront of tech innovation.
Intel(R) Software Adrenaline delivers strategic insight and game-changing
conversations that shape the rapidly evolving mobile landscape. Sign up now.
http://pubads.g.doubleclick.net/gampad/clk?id=63431311&iu=/4140/ostg.clktrk
_______________________________________________
open-cobol-list mailing list
address@hidden
https://lists.sourceforge.net/lists/listinfo/open-cobol-list



reply via email to

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