LIB$SSIGNAL问题与OpenVMS上的-F-atals有关

LIB$SIGNAL issue with -F- atals on OpenVMS

本文关键字:上的 -F-atals 有关 OpenVMS SSIGNAL 问题 LIB      更新时间:2023-10-16

我正在维护一个应用程序,该应用程序必须运行操作Alpha OpenVMS(7.3-2)和安腾OpenVMS。它是用C++编写的,编译器版本在Alpha上为6.5-046,在IA64上为7.4-004。

我遇到的问题是LIB$SIGNAL()。一旦发出致命消息,程序就会中止。

首先是要复制的代码(作为生成和构建代码的DCL脚本):

$ create mtst.msg
.TITLE  Message file for MTST
.IDENT  'VERSION 1.1'
.FACILITY MTST,1 /PREFIX=MTST_
.SEVERITY INFORMATIONAL
HELLO       <Hello World> /fao_count=0
.SEVERITY SUCCESS
SUCCESS     <Opdracht succesvol uitgevoerd> /fao_count=0
.SEVERITY WARNING
WHOOPS      <Dit is een waarschuwing: !AZ> /fao_count=1
.SEVERITY ERROR
WHAAA       <Oeioeioei dat was op het randje> /fao_count=0
.SEVERITY   FATAL
AARGH       <Nu is het helemaal mis> /fao_count=0
.END
$!
$ create msgtest.h
#define __NEW_STARLET 1
#include<lib$routines.h>
#include<stsdef.h>
#pragma extern_model globalvalue
extern unsigned long MTST_HELLO;
extern unsigned long MTST_SUCCESS;
extern unsigned long MTST_WHOOPS;
extern unsigned long MTST_WHAAA;
extern unsigned long MTST_AARGH;
#pragma extern_model relaxed_refdef
$!
$ create msgctest.c
#include<msgtest.h>
#include<stdio>
#include<stdlib.h>
int main(void) {
    char* msgArgument = "Boe!";
    printf ("Test: info message...n");
    LIB$SIGNAL(MTST_HELLO);
    printf("n");
    printf ("Test: success message...n");
    LIB$SIGNAL(MTST_SUCCESS);
    printf("n");
    printf ("Test:  warning message...n");
    LIB$SIGNAL(MTST_WHOOPS, 1, msgArgument);
    printf("n");
    printf ("Test: error message...n");
    LIB$SIGNAL(MTST_WHAAA);
    printf("n");
    printf ("Test: fatal message...n");
    LIB$SIGNAL(MTST_AARGH);
    printf("n");
    printf ("Einde test!n");
}
$!
$ create msgtest.cpp
#include<msgtest.h>
#include<iostream>
#include<stdlib.h>
using namespace std;
#include <chfdef.h>
int main(void) {
    char* msgArgument = "Boe!";
    cout << "Using IOStream:" << endl << "Test: info message..." << endl;
    LIB$SIGNAL(MTST_HELLO);
    cout << endl << "Test: success message..." << endl;
    LIB$SIGNAL(MTST_SUCCESS);
    cout << endl << "Test:  warning message..." << endl;
    LIB$SIGNAL(MTST_WHOOPS, 1, msgArgument);
    cout << endl << "Test: error message..." << endl;
    LIB$SIGNAL(MTST_WHAAA);
    cout << endl << "Test: fatal message..." << endl;
    LIB$SIGNAL(MTST_AARGH);
    // Next line is, of course, never displayed...
    cout << endl << "Einde test!" << endl;
}
$!
$! Compile the message file
$ message mtst
$!
$! As a reference, build an executable using the C-source. Will always work both on Alpha and Itanium
$ cc/lis=[] /include=[] msgctest.c /warn=(disa=dollarid)/notrace
$ link msgctest,mtst  /map=[]/cross/notrace
$!
$! Now build the C++ based exe.
$ cxx/lis=[]/reposi=[] /include=[] msgtest.cpp /warn=(disa=dollarid)/notrace/standard=strict_ansi
$! Using this compile statement it works on Itanium:
$! cxx/lis=[]/reposi=[] /include=[] msgtest.cpp /warn=(disa=dollarid)/notrace
$! Using this compile statement it fails again:
$! cxx/lis=[]/reposi=[] /include=[] msgtest.cpp /warn=(disa=dollarid)/notrace/define=(__USE_STD_IOSTREAM)
$ cxxlink msgtest,mtst /map=[]/cross/notrace
$!

C源始终有效,在Alpha上两个脚本都有效。

在不使用/STSTANDARD的情况下编译时,它在安腾上运行良好,但在最初的程序中,我在使用iostream时遇到了问题:我需要ANSI,但使用/DINIE=(__USE_STD_iostream)进行编译会带回最初的问题。

$r msgtest
Test: info message...
%MTST-I-HELLO, Hello World
Test: success message...
%MTST-S-SUCCESS, Opdracht succesvol uitgevoerd
Test: inwarningfo message...
%MTST-W-WHOOPS, Dit is een waarschuwing: Boe!
Test: error message...
%MTST-E-WHAAA, Oeioeioei dat was op het randje
Test: fatal message...
%CXXL-F-TERMINATING, terminate() or unexpected() called
$

我期待的是:

$ r msgctest
Test: info message...
%MTST-I-HELLO, Hello World
Test: success message...
%MTST-S-SUCCESS, Opdracht succesvol uitgevoerd
Test:  warning message...
%MTST-W-WHOOPS, Dit is een waarschuwing: Boe!
Test: error message...
%MTST-E-WHAAA, Oeioeioei dat was op het randje
Test: fatal message...
%MTST-F-AARGH, Nu is het helemaal mis
$

所以…%CPP--WTF,请帮忙:-/

提前感谢,Oscar

注意:在我昨天写的原始帖子中,有一个不同的脚本,其中包含了一些更多的测试代码,比如try/catch。当然,这改变了用户2116290在他/她的评论中所说的测试结果。我将DCL脚本更改为原始测试,以重现我在原始应用程序中看到的内容。

到目前为止,我还没有发现问题。

$ sh symb x
  X = 134316076   Hex = 0801802C  Octal = 01000300054
$ search *.lis 0801802C/noheader
                         0801802C    13 AARGH       <Nu is het helemaal mis> 

在Alpha上(我在适用于OpenVMS Alpha V8.3的HP C++V7..1-015中尝试过),您正在捕获错误代码。然后你调用abort(),它发出0x434的信号,即OPCCUS,对我来说它看起来还可以

在Alpha上,如果我删除try/catch,则c++程序的行为与c程序相同。我无法使用c++访问I64,所以我无法仔细检查中止()在I64上的结果。它可能只是%CXL-F-终止。

新更新:

看起来严格的ansi模式和标准iostreams的组合触发了一个C++catch-all处理程序,该处理程序捕获致命的VMS条件/异常。在您的示例中,似乎可以使用以下选项禁用捕捉VMS条件:

$ diff -ub old.cpp new.cpp
--- old.cpp     2015-11-11 19:42:52 +0100
+++ new.cpp     2015-11-11 19:49:10 +0100
@@ -1,8 +1,14 @@
 #include<msgtest.h>
 #include<iostream>
 #include<stdlib.h>
+#ifdef __ia64
+#include<cxx_exception.h>
+#endif
 using namespace std;
 int main(void) {
+#ifdef __ia64
+    cxxl$set_condition(pure_unix);
+#endif
     char* msgArgument = "Boe!";
     cout << "Using IOStream:" << endl << "Test: info message..." << endl;
     LIB$SIGNAL(MTST_HELLO);

编译、链接和运行更改后的示例:

    $ cxx /standard=strict_ansi/lis/warn=(disa=dollarid)/notrace/incl=[]/repo=[] new.cpp
    $ link /map=new/full=demangled/cross/notrace new, mtst
    $ r new
    Using IOStream:
    Test: info message...
    %MTST-I-HELLO, Hello World
    Test: success message...
    %MTST-S-SUCCESS, Opdracht succesvol uitgevoerd
    Test:  warning message...
    %MTST-W-WHOOPS, Dit is een waarschuwing: Boe!
    Test: error message...
    %MTST-E-WHAAA, Oeioeioei dat was op het randje
    Test: fatal message...
    %MTST-F-AARGH, Nu is het helemaal mis
    $

也许这对你也有用。