Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Can't open /usr/share/games/fortunes/fortunes.dat.


computers / comp.os.vms / Re: fcntl() exits program and script when /MAIN=POSIX_EXIT defined

SubjectAuthor
* Re: fcntl() exits program and script when /MAIN=POSIX_EXIT definedJake Hamby (Solid State Jake)
+- Re: fcntl() exits program and script when /MAIN=POSIX_EXIT definedCraig A. Berry
`* Re: fcntl() exits program and script when /MAIN=POSIX_EXIT definedhb@end.of.inter.net
 `- Re: fcntl() exits program and script when /MAIN=POSIX_EXIT definedJake Hamby (Solid State Jake)

1
Re: fcntl() exits program and script when /MAIN=POSIX_EXIT defined

<9b20e889-5ed1-4bd5-899d-912d16adc2cdn@googlegroups.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=30590&group=comp.os.vms#30590

  copy link   Newsgroups: comp.os.vms
X-Received: by 2002:ac8:7152:0:b0:415:15f9:c070 with SMTP id h18-20020ac87152000000b0041515f9c070mr10701qtp.6.1697666888304;
Wed, 18 Oct 2023 15:08:08 -0700 (PDT)
X-Received: by 2002:a05:6808:1a01:b0:3ac:abba:fa5b with SMTP id
bk1-20020a0568081a0100b003acabbafa5bmr192812oib.1.1697666888047; Wed, 18 Oct
2023 15:08:08 -0700 (PDT)
Path: i2pn2.org!i2pn.org!news.niel.me!glou.org!news.glou.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.os.vms
Date: Wed, 18 Oct 2023 15:08:07 -0700 (PDT)
In-Reply-To: <74c311c1-3f70-4857-8630-18fd184c1570n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:46b0:abc0:a511:c422:e117:4023;
posting-account=OGFVHQoAAAASiNAamRQec8BtkuXxYFnQ
NNTP-Posting-Host: 2600:1700:46b0:abc0:a511:c422:e117:4023
References: <4855c158-b593-431d-8ab4-22c139ec89f0n@googlegroups.com> <74c311c1-3f70-4857-8630-18fd184c1570n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <9b20e889-5ed1-4bd5-899d-912d16adc2cdn@googlegroups.com>
Subject: Re: fcntl() exits program and script when /MAIN=POSIX_EXIT defined
From: jake.ha...@gmail.com (Jake Hamby (Solid State Jake))
Injection-Date: Wed, 18 Oct 2023 22:08:08 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Jake Hamby (Solid St - Wed, 18 Oct 2023 22:08 UTC

On Wednesday, October 18, 2023 at 3:14:33 AM UTC-7, h47...@gmail.com wrote:
> On Wednesday, October 18, 2023 at 5:38:23 AM UTC+2, Jake Hamby (Solid State Jake) wrote:
> > "perl.c" is in the parent directory of where the test is run, so it compiles, links, and prints "define" to SYS$OUTPUT in the normal case. But when compiled with /main=posix_exit defined, the same program immediately kills not just the process but the running DCL script. Very bizarre.
> In the shown code there is no "return" in main and a "}" is missing. A cut & paste error?
> After adding a "return 0;" and "}" the code works for me - IA64 and x86.
>
> If that doesn't fix your porblem, check $STATUS or enable image accounting to see the exit status after running the image.

Ok, I see where the problem is. I did forget to paste the final "}", but the code that's failing doesn't have a "return 0;" and should still work.

The main() function in C/C++ is special in that it returns int but isn't required to have a return statement. Falling off the end is perfectly valid and should return success.

https://en.cppreference.com/w/cpp/language/main_function

In this case, $STATUS is correctly %X00000001, except with CC and /main=posix_exit. In that case, it's returning %X1035A00A. So it's definitely a bug in VSI C, but not Clang, and the reason it's not printing anything is the same reason that "exit %X1035A00A" isn't printing anything.

$ cc/version
VSI C X7.4-785 (GEM 50X65) on OpenVMS x86_64 V9.2-1

There's nothing wrong with fcntl() at all. The problem is entirely in the C compiler returning the wrong status for /main=posix_exit and falling off the end of main().

Regards,
Jake Hamby

Re: fcntl() exits program and script when /MAIN=POSIX_EXIT defined

<ugq197$3ccv$1@dont-email.me>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=30594&group=comp.os.vms#30594

  copy link   Newsgroups: comp.os.vms
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: craigbe...@nospam.mac.com (Craig A. Berry)
Newsgroups: comp.os.vms
Subject: Re: fcntl() exits program and script when /MAIN=POSIX_EXIT defined
Date: Wed, 18 Oct 2023 20:37:41 -0500
Organization: A noiseless patient Spider
Lines: 27
Message-ID: <ugq197$3ccv$1@dont-email.me>
References: <4855c158-b593-431d-8ab4-22c139ec89f0n@googlegroups.com>
<74c311c1-3f70-4857-8630-18fd184c1570n@googlegroups.com>
<9b20e889-5ed1-4bd5-899d-912d16adc2cdn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Thu, 19 Oct 2023 01:37:43 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="e29ab95f8d91c9c90705f3c6e2077f36";
logging-data="111007"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19KdFqfUjir2tjLU1aqjTIzsQVrSVisdq8="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:1sRLVLq5bW3R/qzsVUsByyyboQo=
Content-Language: en-US
In-Reply-To: <9b20e889-5ed1-4bd5-899d-912d16adc2cdn@googlegroups.com>
 by: Craig A. Berry - Thu, 19 Oct 2023 01:37 UTC

On 10/18/23 5:08 PM, Jake Hamby (Solid State Jake) wrote:
> The problem is entirely in the C compiler returning the wrong status
> for /main=posix_exit and falling off the end of main().

Are you sure it's the C compiler? I doubt that option will work when
building Perl because of its own exit handling, which gives you run-time
control over how exit behavior works. By default, it uses the CRTL
default where "exit 1;" gives you a generic failure and "exit 0;" gives
you a generic success, but you can ask for the exit status to be
interpreted as a VMS condition code:

$ perl -e "exit 1;"
%SYSTEM-F-ABORT, abort
$ show symbol $status
$STATUS == "%X0000002C"
$ perl -e "use vmsish 'exit'; exit 1;"
$ show symbol $status
$STATUS == "%X00000001"

Then there is the logical name PERL_VMS_POSIX_EXIT, which tries to
encode a one-byte POSIX exit status somewhere in one of the upper bytes
of a VMS condition value, meanwhile setting the (hopefully) appropriate
severity bits in the low byte.

Implementing all this stuff couldn't be done by relying on the CRTL's
exit().

Re: fcntl() exits program and script when /MAIN=POSIX_EXIT defined

<fe34bb5f-f887-4642-a2eb-cccac26d1813n@googlegroups.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=30599&group=comp.os.vms#30599

  copy link   Newsgroups: comp.os.vms
X-Received: by 2002:a05:620a:28c3:b0:76f:1eac:e722 with SMTP id l3-20020a05620a28c300b0076f1eace722mr26383qkp.5.1697699021482;
Thu, 19 Oct 2023 00:03:41 -0700 (PDT)
X-Received: by 2002:a05:6830:1d98:b0:6ce:2a70:c74e with SMTP id
y24-20020a0568301d9800b006ce2a70c74emr223477oti.7.1697699021137; Thu, 19 Oct
2023 00:03:41 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!peer02.ams4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.os.vms
Date: Thu, 19 Oct 2023 00:03:40 -0700 (PDT)
In-Reply-To: <9b20e889-5ed1-4bd5-899d-912d16adc2cdn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:9e8:32e2:1000:b3c1:220d:39ad:bc4;
posting-account=U8VIbwoAAAD-oRYtqvRwM1yjdPKmKsbA
NNTP-Posting-Host: 2001:9e8:32e2:1000:b3c1:220d:39ad:bc4
References: <4855c158-b593-431d-8ab4-22c139ec89f0n@googlegroups.com>
<74c311c1-3f70-4857-8630-18fd184c1570n@googlegroups.com> <9b20e889-5ed1-4bd5-899d-912d16adc2cdn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <fe34bb5f-f887-4642-a2eb-cccac26d1813n@googlegroups.com>
Subject: Re: fcntl() exits program and script when /MAIN=POSIX_EXIT defined
From: h47...@gmail.com (hb@end.of.inter.net)
Injection-Date: Thu, 19 Oct 2023 07:03:41 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3225
 by: hb@end.of.inter.net - Thu, 19 Oct 2023 07:03 UTC

On Thursday, October 19, 2023 at 12:08:09 AM UTC+2, Jake Hamby (Solid State Jake) wrote:
....
> Ok, I see where the problem is. I did forget to paste the final "}", but the code that's failing doesn't have a "return 0;" and should still work.

The missing "}" made me wonder if there were more lines missing, which could have included a return statement.
> The main() function in C/C++ is special in that it returns int but isn't required to have a return statement. Falling off the end is perfectly valid and should return success.
>
> https://en.cppreference.com/w/cpp/language/main_function
>
> In this case, $STATUS is correctly %X00000001, except with CC and /main=posix_exit. In that case, it's returning %X1035A00A. So it's definitely a bug in VSI C, but not Clang, and the reason it's not printing anything is the same reason that "exit %X1035A00A" isn't printing anything.

I agree, it's a bug that without an explicit return statement the $STATUS is not a success status.

The URL points to a C++ page, which contains a pointer to a C page. There it says that prior to C99 the exit status without an explicit return statement was undefined. The default for the C compiler on VMS claims to be C99 compliant. Explicitly specifying C99 with the /STANDARD qualifier doesn't change anything, here. And, as you probably know, the /MAIN qualifier is ignored by the current C++ compiler on x86.

In the status code, if bit 0x10000000 is set, no message is printed.
$ exit %X1035A00A
$ exit %X035A00A
%C-E-NOMSG, Message number 0035A00A
$ set message sys$message:decc$msg
$ exit %X035A00A
%C-E-EXIT1, exit value 1
$ It seems, the correct status should be %X1035A009.

Re: fcntl() exits program and script when /MAIN=POSIX_EXIT defined

<5a2a5b8d-7e2a-4e60-966e-cabf79663b23n@googlegroups.com>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=30608&group=comp.os.vms#30608

  copy link   Newsgroups: comp.os.vms
X-Received: by 2002:ac8:4717:0:b0:41b:8260:99f5 with SMTP id f23-20020ac84717000000b0041b826099f5mr54175qtp.7.1697737566300;
Thu, 19 Oct 2023 10:46:06 -0700 (PDT)
X-Received: by 2002:a05:6808:198e:b0:3b2:e46e:448c with SMTP id
bj14-20020a056808198e00b003b2e46e448cmr1020569oib.3.1697737566003; Thu, 19
Oct 2023 10:46:06 -0700 (PDT)
Path: i2pn2.org!rocksolid2!news.neodome.net!news.mixmin.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.os.vms
Date: Thu, 19 Oct 2023 10:46:05 -0700 (PDT)
In-Reply-To: <fe34bb5f-f887-4642-a2eb-cccac26d1813n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:46b0:abc0:452e:161b:329f:5644;
posting-account=OGFVHQoAAAASiNAamRQec8BtkuXxYFnQ
NNTP-Posting-Host: 2600:1700:46b0:abc0:452e:161b:329f:5644
References: <4855c158-b593-431d-8ab4-22c139ec89f0n@googlegroups.com>
<74c311c1-3f70-4857-8630-18fd184c1570n@googlegroups.com> <9b20e889-5ed1-4bd5-899d-912d16adc2cdn@googlegroups.com>
<fe34bb5f-f887-4642-a2eb-cccac26d1813n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5a2a5b8d-7e2a-4e60-966e-cabf79663b23n@googlegroups.com>
Subject: Re: fcntl() exits program and script when /MAIN=POSIX_EXIT defined
From: jake.ha...@gmail.com (Jake Hamby (Solid State Jake))
Injection-Date: Thu, 19 Oct 2023 17:46:06 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
 by: Jake Hamby (Solid St - Thu, 19 Oct 2023 17:46 UTC

On Thursday, October 19, 2023 at 12:03:42 AM UTC-7, h47...@gmail.com wrote:
> On Thursday, October 19, 2023 at 12:08:09 AM UTC+2, Jake Hamby (Solid State Jake) wrote:
> ...
> > Ok, I see where the problem is. I did forget to paste the final "}", but the code that's failing doesn't have a "return 0;" and should still work.
> The missing "}" made me wonder if there were more lines missing, which could have included a return statement.
> > The main() function in C/C++ is special in that it returns int but isn't required to have a return statement. Falling off the end is perfectly valid and should return success.
> >
> > https://en.cppreference.com/w/cpp/language/main_function
> >
> > In this case, $STATUS is correctly %X00000001, except with CC and /main=posix_exit. In that case, it's returning %X1035A00A. So it's definitely a bug in VSI C, but not Clang, and the reason it's not printing anything is the same reason that "exit %X1035A00A" isn't printing anything.
> I agree, it's a bug that without an explicit return statement the $STATUS is not a success status.
>
> The URL points to a C++ page, which contains a pointer to a C page. There it says that prior to C99 the exit status without an explicit return statement was undefined. The default for the C compiler on VMS claims to be C99 compliant. Explicitly specifying C99 with the /STANDARD qualifier doesn't change anything, here. And, as you probably know, the /MAIN qualifier is ignored by the current C++ compiler on x86.
>
> In the status code, if bit 0x10000000 is set, no message is printed.
> $ exit %X1035A00A
> $ exit %X035A00A
> %C-E-NOMSG, Message number 0035A00A
> $ set message sys$message:decc$msg
> $ exit %X035A00A
> %C-E-EXIT1, exit value 1
> $
> It seems, the correct status should be %X1035A009.

Thanks for the info on the status code bits. I didn't catch the release note about /MAIN being ignored by the current x86 C++ compiler, but as you noted, I can't switch the Perl port over to use POSIX exit anyway without breaking a lot of VMS-specific behavior to no benefit.

What I did instead to call POSIX exit() was simply modifying the Configure test and .h file to call __posix_exit() directly. If the version of VMS is too old to support __posix_exit(), then the VMS-specific kill() code can be used, and if it's new enough, then POSIX exit() should be preferable on both C and C++.

I couldn't find any reference as to whether __posix_exit() handles negative values for process ID correctly, but for Perl it doesn't matter because it has its own VMS implementation of killpg() which it uses automatically in that case. Making this change didn't seem to change the outcome of any test cases.

I've found some quite interesting issues with porting Perl to Clang, related to "long" being 8 bytes, having to use 64-bit pointers to get va_list to work, and some unfortunate crashes in early startup. I've also found some general bugs in the Configure script that I'm polishing up the fixes for.

I'm testing my local C++/64-bit-clean changes with the C compiler and its default 32-bit pointers now, to make sure I didn't break anything. I'll push my work to my GitHub fork later today and start a new thread on Clang and LP64 issues.

Best regards,
Jake Hamby

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor