[Top][All Lists]

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

Re: [open-cobol-list] [GNU Cobol 2.0] crash on Solaris (sparc) while exe

From: Paul . Meinhardt
Subject: Re: [open-cobol-list] [GNU Cobol 2.0] crash on Solaris (sparc) while executing SET ADDRESS OF Y2 UP BY 4
Date: Tue, 16 Dec 2014 08:37:56 +0100

thanks for your response. The Solaris problem is currently not urgent. We can postpone the Solaris version of our software until the compiler problem is fixed.

Best Regards

Paul Meinhardt  

From:        Ron Norman <address@hidden>
To:        address@hidden
Date:        15.12.2014 16:08
Subject:        Re: [open-cobol-list] [GNU Cobol 2.0] crash on Solaris (sparc) while executing SET ADDRESS OF Y2 UP BY 4

I have verified this is a bug in OpenCOBOL 1.1 and GNUCobol as well. 
The program works on x86 but not on Sun due to differences in the generated code due to hardware differences.
The sample code is correct and does work using Micro Focus COBOL.

It will just take a bit of time to work up the solution, test it and post it back.

On Mon, Dec 15, 2014 at 5:12 AM, <address@hidden> wrote:

the following small program causes a crash (Signal SIGSEGV) on Solaris (sparc). The same program runs without problems on Windows and shows the expected results.

prog.cob: 16: Attempt to reference unallocated memory (Signal SIGSEGV)

Abnormal termination - File contents may be incorrect

I used the gnu cobol branch 2.0 r470


       PROGRAM-ID.      prog.

       DATA             DIVISION.


       01 XX.

         02 XX-1           PIC X(4) VALUE "1234".

         02 XX-2           PIC X(4) VALUE "5678".

       01 P-XX-1        POINTER.

       01 P-XX-2        POINTER.

       LINKAGE          SECTION.

       01 Y2            PIC X(4).


         SET P-XX-1 TO ADDRESS OF XX-1

         SET P-XX-2 TO ADDRESS OF XX-2


         SET ADDRESS OF Y2 UP BY 4

         IF Y2 NOT = XX-2

            DISPLAY "Test 2 '" Y2 "'"



         IF ADDRESS OF Y2 NOT= P-XX-2

            DISPLAY "Pointer test failed"


         STOP RUN.


The crash occurs in the first memcpy call of

cob_pointer_manip (cob_field *f1, cob_field *f2, const unsigned int addsub)


        unsigned char   *tmptr;

        memcpy (&tmptr, f1->data, sizeof(void *));

        if (addsub) {

                tmptr -= cob_get_int (f2);

        } else {

                tmptr += cob_get_int (f2);


        memcpy (f1->data, &tmptr, sizeof(void *));


the following call to cob_pointer_manip in the generated C code shows the problem:

  /* Line: 16        : SET                : prog.cob */

  cob_set_location (st_1, 16, NULL, NULL, st_2);

  cob_pointer_manip (b_10, (cob_field *)&c_1, 0);

the variable b_10 is defined as:

/* LINKAGE SECTION (Items not referenced by USING clause) */

static unsigned char        *b_10 = NULL;  /* Y2 */

but the cob_pointer_manip function expects a pointer to a cob_field structure and therefore f1->data points to nowhere.

During compilation I get the following warnings:

address@hidden: ~/pme-test/cob-address $ cobc -g -x prog.cob

prog.c: In function 'prog_':

prog.c:124:3: warning: passing argument 1 of 'cob_pointer_manip' from incompatible pointer type

prog.c.h:33:1: note: expected 'struct cob_field *' but argument is of type 'unsigned char *'

The enclosed ZIP ( file contains the sample program and the generated C source and contains the configure log file.

Some data about my solaris system:

uname -a

SunOS sol10d 5.10 Generic_142909-17 sun4u sparc SUNW,Sun-Fire-V440

Any suggestions?

Best Regards

Paul Meinhardt  

Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
open-cobol-list mailing list


Ron Norman

reply via email to

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