C compiler crash

Post Reply

Topic author
mjvms27
Contributor
Posts: 19
Joined: Wed May 17, 2023 2:11 pm
Reputation: 0
Status: Offline

C compiler crash

Post by mjvms27 » Wed May 24, 2023 12:44 pm

Here is an illustrative example of the X86_64 VSI C compiler triggering an access violation when compiling test2.c in the following test case scenario, when you do not specify cc/names=(as_is) on the compile command line.

A link error would be the expected outcome, but not the compiler access violation on the compile of test2.c
$ cc /version
VSI C X7.4-726 (GEM 50X23) on OpenVMS x86_64 E9.2-1

test1.c

Code: Select all

#include <stdlib.h>
#include <stdio.h>

extern char *add_article(const char *a, const char *t, char *b, size_t s);
extern char *Add_article(const char *a, const char *t, char *b, size_t s);

char my_text[80];
const char *my_article = "the",
           *phrase = "rain in spain stays mainly on the plain.";

int main(int argc, char *argv[])
{
    printf("%s\n",
           Add_article(my_article, phrase, my_text, sizeof my_text));
    printf("Repeat, %s\n",
           add_article(my_article, phrase, my_text, sizeof my_text));
    return EXIT_SUCCESS;
}
test2.c

Code: Select all

#include <stdlib.h>
#include <stdio.h>

char *add_article(const char *article, const char *txt, char *bf, size_t bsize)
{
    (void) snprintf(bf, bsize, "%s %s", article, txt);
    return bf;
}

char *Add_article(const char *article, const char *txt, char *bf, size_t bsize)
{
    char *r = add_article(article, txt, bf, bsize);
    if (r && *r >= 'a' && *r <= 'z')
        *r &= ~0x20;
    return r;
}
$ cc test1.c
$! successful compile

$ cc test2.c
$! Here is the compiler crash if test2.c is compiled as on line above, without /names=(as_is).

Code: Select all

%SYSTEM-F-ACCVIO, access violation, reason mask=04, virtual address=000000000000
0028, PC=0000000001130721, PS=0000001B
%TRACE-F-TRACEBACK, symbolic stack dump follows
image     module    routine               line      rel PC           abs PC
DECC$COMPILER                                0 0000000001130721 0000000001130721
DECC$COMPILER                                0 0000000001096D15 0000000001096D15
DECC$COMPILER  [.src]g2l_symbol.cxx  InsertAtEnd
                                          #948 0000000000A508DF 0000000000A508DF
DECC$COMPILER  [.src]g2l_symbol.cxx  convertSymbol
                                          #706 0000000000A4F1F5 0000000000A4F1F5
DECC$COMPILER  [.src]g2l_module.cxx  convertDeclarations
                                         #1487 0000000000A4D348 0000000000A4D348
DECC$COMPILER  [.src]g2l_module.cxx  convertDeclarations
                                         #1502 0000000000A4D440 0000000000A4D440
DECC$COMPILER  [.src]g2l_module.cxx  convertModule
                                         #1123 0000000000A4A588 0000000000A4A588
DECC$COMPILER  [.src]g2l_module.cxx  G2L_COMPILE_MODULE
                                          #593 0000000000A49181 0000000000A49181
DECC$COMPILER  GEM_VER_AREA:<SRC>GEM_CO.BLI;1  GEM_CO_COMPILE_MODULE
                                         #3413 00000000006E2627 00000000006E2627
DECC$COMPILER  COMPILE.C;1  gemc_be_master
                                       #103705 00000000004236FE 00000000004236FE
DECC$COMPILER  COMPILE.C;1  gem_xx_compile
                                       #102916 00000000004223D7 00000000004223D7
DECC$COMPILER  GEM_VER_AREA:<SRC>GEM_CP_VMS.BLI;1  GEM_CP_MAIN
                                         #2643 00000000006D4C1E 00000000006D4C1E
DECC$COMPILER                                0 0000000000AD76D4 0000000000AD76D4
DECC$COMPILER                                0 00000000020F6D6D 00000000020F6D6D
PTHREAD$RTL                                  0 000000008004122C FFFF830008D0322C
PTHREAD$RTL                                  0 0000000080002316 FFFF830008CC4316
                                             0 FFFF8300071FBDC6 FFFF8300071FBDC6
DCL                                          0 000000008006741B 000000007ADFF41B
%TRACE-I-LINENUMBER, Leading '#' specifies a source file record number.
%TRACE-I-END, end of TRACE stack dump
Last edited by mjvms27 on Wed May 24, 2023 12:51 pm, edited 1 time in total.

Tags:


jreagan
VSI Expert
Master
Posts: 133
Joined: Tue Dec 01, 2020 8:40 am
Reputation: 0
Status: Offline

Re: C compiler crash

Post by jreagan » Wed May 24, 2023 1:26 pm

Noted. I'll add to our list.


hb
Valued Contributor
Posts: 57
Joined: Mon May 01, 2023 12:11 pm
Reputation: 0
Status: Offline

Re: C compiler crash

Post by hb » Thu May 25, 2023 6:20 am

mjvms27 wrote:
Wed May 24, 2023 12:44 pm
A link error would be the expected outcome, ...
No.

When the sources are compiled without /names=(as_is), you will see %CC-W-DUPEXTERN warnings, but you will get object modules.
Linking them will result in link warnings, %ILINK-W-COMPWARN for each module plus a %ILINK-W-MULDEF for the second object module in your link. You will get an image. Running it will "Repeat" the exact same string.

Post Reply