gnucobol-users
[Top][All Lists]
Advanced

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

Re: [open-cobol-list] open-cobol-list Digest, Vol 86, Issue 3


From: James Lemmon
Subject: Re: [open-cobol-list] open-cobol-list Digest, Vol 86, Issue 3
Date: Mon, 15 Dec 2014 16:36:18 +0200

Are you calling the program from another program or trying to run it on its own?

Y2 must be linked, during a call or else the data is unpredictable as the pointers to the calling program would need to be set up for the called program to be able to use Y2.

On Mon, Dec 15, 2014 at 3:20 PM, <address@hidden> wrote:
Send open-cobol-list mailing list submissions to
        address@hidden

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.sourceforge.net/lists/listinfo/open-cobol-list
or, via email, send a message with subject or body 'help' to
        address@hidden

You can reach the person managing the list at
        address@hidden

When replying, please edit your Subject line so it is more specific
than "Re: Contents of open-cobol-list digest..."


Today's Topics:

   1. Re: open-cobol-list Digest, Vol 86, Issue 2 (James Lemmon)
   2. Re: [GNU Cobol 2.0] crash on Solaris (sparc) while executing
      SET ADDRESS OF Y2 UP BY 4 (address@hidden)


----------------------------------------------------------------------

Message: 1
Date: Mon, 15 Dec 2014 14:14:02 +0200
From: James Lemmon <address@hidden>
Subject: Re: [open-cobol-list] open-cobol-list Digest, Vol 86, Issue 2
To: address@hidden
Message-ID:
        <CA+pcQxy-Dq92Z95n+o7Bh5+P8ama4B6GpWdcYcD=address@hidden>
Content-Type: text/plain; charset="utf-8"

Any linkage item is passed to a program in a call statement and must be
declared with a using clause in the Procedure Division heading, if it is
referenced in the program, which in the example would be PROCEDURE DIVISION
USING Y2.


Best Regards

On Mon, Dec 15, 2014 at 12:12 PM, <
address@hidden> wrote:
>
> Send open-cobol-list mailing list submissions to
>         address@hidden
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://lists.sourceforge.net/lists/listinfo/open-cobol-list
> or, via email, send a message with subject or body 'help' to
>         address@hidden
>
> You can reach the person managing the list at
>         address@hidden
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of open-cobol-list digest..."
>
>
> Today's Topics:
>
>    1. [GNU Cobol 2.0] crash on Solaris (sparc) while executing SET
>       ADDRESS OF Y2 UP BY 4 (address@hidden)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 15 Dec 2014 11:12:15 +0100
> From: address@hidden
> Subject: [open-cobol-list] [GNU Cobol 2.0] crash on Solaris (sparc)
>         while executing SET ADDRESS OF Y2 UP BY 4
> To: address@hidden
> Message-ID:
>         <
> address@hidden>
>
> Content-Type: text/plain; charset="us-ascii"
>
> Hello,
>
> 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
>
>        IDENTIFICATION   DIVISION.
>        PROGRAM-ID.      prog.
>        DATA             DIVISION.
>        WORKING-STORAGE  SECTION.
>        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).
>        PROCEDURE        DIVISION.
>          SET P-XX-1 TO ADDRESS OF XX-1
>          SET P-XX-2 TO ADDRESS OF XX-2
>          SET ADDRESS OF Y2 TO ADDRESS OF XX-1
>          SET ADDRESS OF Y2 UP BY 4
>          IF Y2 NOT = XX-2
>             DISPLAY "Test 2 '" Y2 "'"
>             END-DISPLAY
>          END-IF
>          IF ADDRESS OF Y2 NOT= P-XX-2
>             DISPLAY "Pointer test failed"
>          END-IF
>          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 (crash.zip) file contains the sample program and the
> generated C source and config.log.zip 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
> (Development)
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: crash.zip
> Type: application/zip
> Size: 3667 bytes
> Desc: not available
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: config.log.zip
> Type: application/zip
> Size: 14799 bytes
> Desc: not available
>
> ------------------------------
>
>
> ------------------------------------------------------------------------------
> 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
>
> http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
>
> ------------------------------
>
> _______________________________________________
> open-cobol-list mailing list
> address@hidden
> https://lists.sourceforge.net/lists/listinfo/open-cobol-list
>
>
> End of open-cobol-list Digest, Vol 86, Issue 2
> **********************************************
>


--
James Lemmon
Cell +27825663095
-------------- next part --------------
An HTML attachment was scrubbed...

------------------------------

Message: 2
Date: Mon, 15 Dec 2014 14:20:11 +0100
From: address@hidden
Subject: Re: [open-cobol-list] [GNU Cobol 2.0] crash on Solaris
        (sparc) while executing SET ADDRESS OF Y2 UP BY 4
To: James Lemmon <address@hidden>
Cc: address@hidden
Message-ID:
        <address@hidden>

Content-Type: text/plain; charset="us-ascii"

Hello,

thanks for your response.

I changed the program as you suggested but the code generation is not
affected.
GNU Cobol still generates this C code:

  /* Line: 18        : SET                : prog.cob */
  cob_set_location (st_1, 18, NULL, NULL, st_2);
  cob_pointer_manip (b_10, (cob_field *)&c_1, 0);

The compiler warnings (and the crash) are still there:

address@hidden: ~/pme-test/cob-address $ cobc -x -g call-it.cob prog.cob
prog.c: In function 'prog_':
prog.c:116: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 *'
address@hidden: ~/pme-test/cob-address $ cobc -g -C call-it.cob prog.cob
address@hidden: ~/pme-test/cob-address $ ./call-it

prog.cob: 18: Attempt to reference unallocated memory (Signal SIGSEGV)
Abnormal termination - File contents may be incorrect
address@hidden: ~/pme-test/cob-address $



Best Regards

Paul Meinhardt
(Development)

James Lemmon <address@hidden> wrote on 15.12.2014 13:14:02:

> From: James Lemmon <address@hidden>
> To: address@hidden
> Date: 15.12.2014 13:14
> Subject: Re: [open-cobol-list] open-cobol-list Digest, Vol 86, Issue 2
>
> Any linkage item is passed to a program in a call statement and must
> be declared with a using clause in the Procedure Division heading,
> if it is referenced in the program, which in the example would be
> PROCEDURE DIVISION USING Y2.
>
> Best Regards
>
> On Mon, Dec 15, 2014 at 12:12 PM, <open-cobol-list-
> address@hidden> wrote:
> Send open-cobol-list mailing list submissions to
>         address@hidden
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://lists.sourceforge.net/lists/listinfo/open-cobol-list
> or, via email, send a message with subject or body 'help' to
>         address@hidden
>
> You can reach the person managing the list at
>         address@hidden
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of open-cobol-list digest..."
>
>
> Today's Topics:
>
>    1. [GNU Cobol 2.0] crash on Solaris (sparc) while executing SET
>       ADDRESS OF Y2 UP BY 4 (address@hidden)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 15 Dec 2014 11:12:15 +0100
> From: address@hidden
> Subject: [open-cobol-list] [GNU Cobol 2.0] crash on Solaris (sparc)
>         while executing SET ADDRESS OF Y2 UP BY 4
> To: address@hidden
> Message-ID:
>
<address@hidden
> >
>
> Content-Type: text/plain; charset="us-ascii"
>
> Hello,
>
> 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
>
>        IDENTIFICATION   DIVISION.
>        PROGRAM-ID.      prog.
>        DATA             DIVISION.
>        WORKING-STORAGE  SECTION.
>        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).
>        PROCEDURE        DIVISION.
>          SET P-XX-1 TO ADDRESS OF XX-1
>          SET P-XX-2 TO ADDRESS OF XX-2
>          SET ADDRESS OF Y2 TO ADDRESS OF XX-1
>          SET ADDRESS OF Y2 UP BY 4
>          IF Y2 NOT = XX-2
>             DISPLAY "Test 2 '" Y2 "'"
>             END-DISPLAY
>          END-IF
>          IF ADDRESS OF Y2 NOT= P-XX-2
>             DISPLAY "Pointer test failed"
>          END-IF
>          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 (crash.zip) file contains the sample program and the
> generated C source and config.log.zip 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
> (Development)
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: crash.zip
> Type: application/zip
> Size: 3667 bytes
> Desc: not available
> -------------- next part --------------
> A non-text attachment was scrubbed...
> Name: config.log.zip
> Type: application/zip
> Size: 14799 bytes
> Desc: not available
>
> ------------------------------
>
>
------------------------------------------------------------------------------
> 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
>
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk

>
> ------------------------------
>
> _______________________________________________
> open-cobol-list mailing list
> address@hidden
> https://lists.sourceforge.net/lists/listinfo/open-cobol-list
>
>
> End of open-cobol-list Digest, Vol 86, Issue 2
> **********************************************
>
>
> --
> [image removed]
> James Lemmon
> Cell +27825663095
>
------------------------------------------------------------------------------
> 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
>
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk

> _______________________________________________
> open-cobol-list mailing list
> address@hidden
> https://lists.sourceforge.net/lists/listinfo/open-cobol-list
-------------- next part --------------
An HTML attachment was scrubbed...

------------------------------

------------------------------------------------------------------------------
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
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk

------------------------------

_______________________________________________
open-cobol-list mailing list
address@hidden
https://lists.sourceforge.net/lists/listinfo/open-cobol-list


End of open-cobol-list Digest, Vol 86, Issue 3
**********************************************


--
James Lemmon
Cell +27825663095

reply via email to

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