Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Outside of a dog, a book is man's best friend. Inside of a dog, it is too dark to read.


computers / news.software.nntp / Re: Libraries using longjmp for error handling

SubjectAuthor
* More on NNTP testingJohann 'Myrkraverk' Oskarsson
+- Re: More on NNTP testingJon Ribbens
+* Re: More on NNTP testingRichard Kettlewell
|`* Libraries using longjmp for error handling (was: Re: More on NNTPBlue-Maned_Hawk
| `- Re: Libraries using longjmp for error handlingRichard Kettlewell
`- Re: More on NNTP testingDoc O'Leary ,

1
More on NNTP testing

<65SQM.565977$9o89.411905@fx05.ams4>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=2162&group=news.software.nntp#2162

  copy link   Newsgroups: news.software.nntp
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!hirsch.in-berlin.de!bolzen.all.de!npeer.as286.net!npeer-ng0.as286.net!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!fx05.ams4.POSTED!not-for-mail
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.15.1
Newsgroups: news.software.nntp
Content-Language: en-US
From: johann@myrkraverk.invalid (Johann 'Myrkraverk' Oskarsson)
Subject: More on NNTP testing
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Lines: 47
Message-ID: <65SQM.565977$9o89.411905@fx05.ams4>
X-Complaints-To: abuse@easynews.com
Organization: Easynews - www.easynews.com
X-Complaints-Info: Please be sure to forward a copy of ALL headers otherwise we will be unable to process your complaint properly.
Date: Wed, 27 Sep 2023 16:54:24 +0800
X-Received-Bytes: 2497
 by: Johann 'Myrkrav - Wed, 27 Sep 2023 08:54 UTC

Dear news.software.nntp,

As per my previous thread, I've started experimenting with NNTP.

I first set up INN in a VM that I'm "talking to" for the moment.

So testing things that work is easy. What I'm more concerned with,
right now, is the negative testing: testing the things that shouldn't
work. [Something that most programmers forget to do.]

So, I can trivially create /an NNTP server/ that replies with the wrong
greeting line, or perhaps no line at all.

What I'm wondering about, is how the software should behave if the first
line is simply invalid. There are various cases, such as

1) the initial greeting never arrives,

2) the initial response code is not one of 200, 201, 400, 502,

3) the initial response line does not terminate with CR LF within
512 octets,

4) the byte following the response code is not space.

Reading RFC 3977, section 3.1, I can get the sense that

201This is a valid response line CR LF

but nobody does it in practice? [Note, the CR LF is meant without
space separation in my example.] Spec lawyers would be helpful here,
maybe.

It's easy to create these examples, and then have an NNTP library return
or throw an error (yes, even in C; we just use longjmp()), but how would
end user software want to deal with such cases?

How do people using newsreaders want to log such errors, and/or complain
about it? To whom?

Having some answers to these questions may help me determine how I
structure my library, and create a newsreader.

Thanks,
--
Johann | email: invalid -> com | www.myrkraverk.com/blog/
I'm not from the Internet, I just work there. | twitter: @myrkraverk

Re: More on NNTP testing

<slrnuh84um.78e.jon+usenet@raven.unequivocal.eu>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=2163&group=news.software.nntp#2163

  copy link   Newsgroups: news.software.nntp
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jon+usenet@unequivocal.eu (Jon Ribbens)
Newsgroups: news.software.nntp
Subject: Re: More on NNTP testing
Date: Wed, 27 Sep 2023 11:36:54 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <slrnuh84um.78e.jon+usenet@raven.unequivocal.eu>
References: <65SQM.565977$9o89.411905@fx05.ams4>
Injection-Date: Wed, 27 Sep 2023 11:36:54 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="21d7de4ccc5decf14936e0997709aa2a";
logging-data="3220818"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18oDY0K55toEiBhQqu0C37sBx+C74iNmmY="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:vy/vrzbxCM5u/Bx3kjHVirhMxak=
 by: Jon Ribbens - Wed, 27 Sep 2023 11:36 UTC

On 2023-09-27, Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> wrote:
> So testing things that work is easy. What I'm more concerned with,
> right now, is the negative testing: testing the things that shouldn't
> work. [Something that most programmers forget to do.]
>
> So, I can trivially create /an NNTP server/ that replies with the wrong
> greeting line, or perhaps no line at all.

Throw an error. The Robustness Principle is wrong. Do not be "liberal
in what you accept" - that way lies madness.

> Reading RFC 3977, section 3.1, I can get the sense that
>
> 201This is a valid response line CR LF

No. Section 3.2: Arguments MUST be separated from the numeric status
indicator and from each other by a single space."

> It's easy to create these examples, and then have an NNTP library return
> or throw an error (yes, even in C; we just use longjmp()), but how would
> end user software want to deal with such cases?
>
> How do people using newsreaders want to log such errors, and/or complain
> about it? To whom?

My personal recommendation is to show a human-friendly error whenever
you can, but there absolutely must be a way for the user to press a
button or something to see the raw network data (and bear in mind the
possibility of binary data) so that they can give helpful diagnostic
information to the server operator if necessary.

Re: More on NNTP testing

<wwvpm23d9fr.fsf@LkoBDZeT.terraraq.uk>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=2164&group=news.software.nntp#2164

  copy link   Newsgroups: news.software.nntp
Path: i2pn2.org!i2pn.org!news.nntp4.net!nntp.terraraq.uk!.POSTED.tunnel.sfere.anjou.terraraq.org.uk!not-for-mail
From: invalid@invalid.invalid (Richard Kettlewell)
Newsgroups: news.software.nntp
Subject: Re: More on NNTP testing
Date: Wed, 27 Sep 2023 14:36:56 +0100
Organization: terraraq NNTP server
Message-ID: <wwvpm23d9fr.fsf@LkoBDZeT.terraraq.uk>
References: <65SQM.565977$9o89.411905@fx05.ams4>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: innmantic.terraraq.uk; posting-host="tunnel.sfere.anjou.terraraq.org.uk:172.17.207.6";
logging-data="55543"; mail-complaints-to="usenet@innmantic.terraraq.uk"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:emCPtcCXwcBIvvlQ8d+psP6nqp4=
X-Face: h[Hh-7npe<<b4/eW[]sat,I3O`t8A`(ej.H!F4\8|;ih)`7{@:A~/j1}gTt4e7-n*F?.Rl^
F<\{jehn7.KrO{!7=:(@J~]<.[{>v9!1<qZY,{EJxg6?Er4Y7Ng2\Ft>Z&W?r\c.!4DXH5PWpga"ha
+r0NzP?vnz:e/knOY)PI-
X-Boydie: NO
 by: Richard Kettlewell - Wed, 27 Sep 2023 13:36 UTC

Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> writes:
> It's easy to create these examples, and then have an NNTP library return
> or throw an error (yes, even in C; we just use longjmp()), but how would
> end user software want to deal with such cases?

It’s more than 20 years since I last had to integrate a C library which
reported errors via longjmp() and I’m still bitter about it. As a matter
of API design, I’d rather C library communicated errors via return
values (and pointer parameters, where more complex error information is
required).

I’m not 100% convinced that a general-purpose NNTP library is a very
useful thing. NNTP just isn’t really the hard bit. (NNTP-related
functionality would no doubt be a distinct module within a newsreader,
but with an API friendly to how the rest of the newsreader worked.)

> How do people using newsreaders want to log such errors, and/or complain
> about it? To whom?

If the news server is just plain broken then a single error message in
the UI would seem appropriate.

--
https://www.greenend.org.uk/rjk/

Libraries using longjmp for error handling (was: Re: More on NNTP testing)

<pan$6f4ce$6edf891e$2b5c40c1$f8f989c1@invalid.invalid>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=2165&group=news.software.nntp#2165

  copy link   Newsgroups: news.software.nntp comp.lang.c
Followup: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!bluemanedhawk.eternal-september.org!.POSTED!not-for-mail
From: bluemanedhawk@invalid.invalid (Blue-Maned_Hawk)
Newsgroups: news.software.nntp,comp.lang.c
Subject: Libraries using longjmp for error handling (was: Re: More on NNTP
testing)
Followup-To: comp.lang.c
Date: Wed, 27 Sep 2023 22:52:59 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 37
Message-ID: <pan$6f4ce$6edf891e$2b5c40c1$f8f989c1@invalid.invalid>
References: <65SQM.565977$9o89.411905@fx05.ams4>
<wwvpm23d9fr.fsf@LkoBDZeT.terraraq.uk>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 27 Sep 2023 22:52:59 -0000 (UTC)
Injection-Info: bluemanedhawk.eternal-september.org; posting-host="2130bf3c74c20cbf06e8b31893e9df54";
logging-data="3495454"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Iys1nkcsKOyUrvUrc2S0L1L63GRKgU+E="
User-Agent: Pan/0.154 (Izium; 517acf4)
Cancel-Lock: sha1:OQANcn/gOf9zbtXJAZnpDa7qS3U=
X-Face: Llanfair­pwllgwyngyllÃ
ƒ‚Ã
ƒƒ‚­gogery­chwyrnÃ
ƒƒ
? ?‚­drobwll­llan
Ã
? ?ƒƒ‚­tysilio­go
g
o­goch
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAACh0lEQVRYw71Z21bD
MAzzevbfkr4cHjrSXJyL044+MDa6WLEl2SkvkrZ1AbAvXO+bUGSCPYnsuIVGMpm
ZLnjX718GhAKNsp8lON2F9VrhELwIgJlBepkZjA78rVK+FkmNhEJK76UsJlz8+E
rJsjrpYouhLo/SC6qPHgakFOR8wV9+8rCfO/I/oVnmUZUp42/LW2XkLj9TCFNM9
jp5g2EmHZgpYZjCOkYU7sXVogRylJqpdggoFLG1g09Flah/7kErCxzR9HgXPYsq
0glb9cxjIz2Vsk9AmAoCSxECpD713joMKjQqLAtmMqJmXjdVvlMnMQCVITotJd1
z+fh1f1NNo+vuc1KnhWUmY7t03vydTud9BbXCtN3L2PL3bK7JCNG0GHzuZxafyB
fxevCxpm1vrwZltqw6SILCcdoCE6PGQC8wZWDA9Or7Qp5s3lAZezys0nDazs9S9
R0TjwEiksRxLkNPC1NMMWPs1bj0Ei0Yuo+JVtFLuzP1NRJ16qXWN8DhhtmS4PDg
O6mqRxs4bEJrYt087mSIow/1VzW2oFlMQuiuIy/KsUagvhdw6hSjJGlIavbLF8x
j3X47bccLcUSi0dkWh1nUZNhANT1tHKUXrNxNLbd9KPb9wDDVrKwmPQMOPQ1oy6
k5I1DwzDeRJd3jVIhDAUxq3ngzJG4CCkNXZxZVMcjefoK2J0gUY2S3rxz/RuTFx
2zHd9U+obimJXMG4edsk/2j5pTU5G1MmzbRLxkfq5EiT1GGsidvMGzi+1goGb2l
GCrN+nGnV8xj3q3JLRDVPL96vUc7Z4aJ3TN1mVqWAMJMfG+Jxh6TQqP+92iZkCU
xtglds1AB6r0aiSHKcnFck+p/c/0CbacFLQcajGcAAAAASUVORK5CYII=
 by: Blue-Maned_Hawk - Wed, 27 Sep 2023 22:52 UTC

Richard Kettlewell wrote:

> It’s more than 20 years since I last had to integrate a C library which
> reported errors via longjmp() and I’m still bitter about it.

I have never encountered a library which does that. Which library was
that?

> As a matter of API design, I’d rather C library communicated errors via
> return values (and pointer parameters, where more complex error
> information is required).

Personally, i think that, at least for a library, an error should _only_
be communicated by return value. If more complex information is required,
then the return value can be made more complex. I don't think i've ever
used a library that communicates information via a pointer parameter.

One thing i've experienced in multiple libraries is a system a bit like
what errno.h offers, but done via a pair of subroutines that retrieve and
assign to some hidden global variable. I don't like this for the same
reason i don't like subroutines that use errno (unless they're syscall
wrappers), but in at least two of the cases the library has also come with
a way to set a callback subroutine to automatically deal with errors
instead. This is nice, since it means that the code doesn't get all
obfuscated with error checking after every subroutine call, but it's
annoying that each library needs to come with its own unique subroutine
for this, and i do worry about it being overly general in treating all
errors lethally.

--
Blue-Maned_Hawk│shortens to
Hawk│/
blu.mɛin.dÊ°ak/
│he/him/his/himself/Mr. bluemanedhawk.github.io
Warning: Low flying owls. Lost chihuahua.

Re: More on NNTP testing

<uf7iuf$fr47$1@dont-email.me>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=2166&group=news.software.nntp#2166

  copy link   Newsgroups: news.software.nntp
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: droleary.usenet@2023.impossiblystupid.com (Doc O'Leary ,)
Newsgroups: news.software.nntp
Subject: Re: More on NNTP testing
Date: Fri, 29 Sep 2023 22:26:23 -0000 (UTC)
Organization: Subsume Technologies, Inc.
Lines: 56
Message-ID: <uf7iuf$fr47$1@dont-email.me>
References: <65SQM.565977$9o89.411905@fx05.ams4>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 29 Sep 2023 22:26:23 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="9ae8e5ce7623a83dd94aa1e7790cb081";
logging-data="519303"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+UiH8nx8YCxRtEyyrDnU0/xED3BI1pQA4="
User-Agent: com.subsume.NNTP/1.0.0
Cancel-Lock: sha1:LXvui5ap5IOFjxsThFv+l+jd+3Q=
 by: Doc O'Leary , - Fri, 29 Sep 2023 22:26 UTC

For your reference, records indicate that
Johann 'Myrkraverk' Oskarsson <johann@myrkraverk.invalid> wrote:

> What I'm wondering about, is how the software should behave if the first
> line is simply invalid.

It is entirely up to you how to architect your software. How you do or don’t
abstract away lower levels is always a matter of trade-offs, and they may
have a significant impact on how you provide functionality at a higher level.

For example, if you want to provide an “offline” mode, something somewhere
inside your code needs to make the determination of what can be done in that
mode. And that includes what happens if you fail to go “online” for
*whatever* reason. It’s not such a problem these days with broadband like it
was back in the days of dialup, but it *is* somewhat related to command
pipelining, too, so keep that in mind as you make your decisions.

For my framework, I made the decision to have different objects for the
server and the session/connection to that server. The groups and article
objects deal with only servers, and it is up to the servers to manage their connection(s).

> Reading RFC 3977, section 3.1, I can get the sense that
>
> 201This is a valid response line CR LF
>
> but nobody does it in practice?

As Jon said, that’s not strictly valid, but my parser would certainly accept
it, because I’m looking for any integer (not just a 3 digit one) and then
skipping any amount of whitespace (including none). I obviously disagree
with Jon, and I intentionally tried to be more permissive than the standard
to future-proof my code to some degree. If you want to write a validating
framework, you’re welcome to do so; I just wanted a functional one.

> It's easy to create these examples, and then have an NNTP library return
> or throw an error (yes, even in C; we just use longjmp()), but how would
> end user software want to deal with such cases?

At some level, they just don’t care about any of that. They just want to
know what new messages there are, or they just want to post a reply. If it
comes back as “0 new messages” or “saved to outgoing messages”, that might
be a big deal, and it might not be. In my book, not every transient
network error deserves a be a red alert.

> How do people using newsreaders want to log such errors, and/or complain
> about it? To whom?

Different people will care to different degrees. You’ll never be able to
please all the people all the time. Generally, people want software that
*works*, not error logs that tell them in exquisite detail why it doesn’t.

--
"Also . . . I can kill you with my brain."
River Tam, Trash, Firefly

Re: Libraries using longjmp for error handling

<wwvil7sxdig.fsf@LkoBDZeT.terraraq.uk>

  copy mid

https://www.rocksolidbbs.com/computers/article-flat.php?id=2167&group=news.software.nntp#2167

  copy link   Newsgroups: news.software.nntp comp.lang.c
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!nntp.terraraq.uk!.POSTED.tunnel.sfere.anjou.terraraq.org.uk!not-for-mail
From: invalid@invalid.invalid (Richard Kettlewell)
Newsgroups: news.software.nntp,comp.lang.c
Subject: Re: Libraries using longjmp for error handling
Date: Sat, 30 Sep 2023 09:37:43 +0100
Organization: terraraq NNTP server
Message-ID: <wwvil7sxdig.fsf@LkoBDZeT.terraraq.uk>
References: <65SQM.565977$9o89.411905@fx05.ams4>
<wwvpm23d9fr.fsf@LkoBDZeT.terraraq.uk>
<pan$6f4ce$6edf891e$2b5c40c1$f8f989c1@invalid.invalid>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: innmantic.terraraq.uk; posting-host="tunnel.sfere.anjou.terraraq.org.uk:172.17.207.6";
logging-data="114358"; mail-complaints-to="usenet@innmantic.terraraq.uk"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)
Cancel-Lock: sha1:+C7u7K71lS/9FNLh9qUvAXaiHb4=
X-Face: h[Hh-7npe<<b4/eW[]sat,I3O`t8A`(ej.H!F4\8|;ih)`7{@:A~/j1}gTt4e7-n*F?.Rl^
F<\{jehn7.KrO{!7=:(@J~]<.[{>v9!1<qZY,{EJxg6?Er4Y7Ng2\Ft>Z&W?r\c.!4DXH5PWpga"ha
+r0NzP?vnz:e/knOY)PI-
X-Boydie: NO
 by: Richard Kettlewell - Sat, 30 Sep 2023 08:37 UTC

Blue-Maned_Hawk <bluemanedhawk@invalid.invalid> writes:
> Richard Kettlewell wrote:
>> It’s more than 20 years since I last had to integrate a C library which
>> reported errors via longjmp() and I’m still bitter about it.
>
> I have never encountered a library which does that. Which library was
> that?

libpng

>> As a matter of API design, I’d rather C library communicated errors
>> via return values (and pointer parameters, where more complex error
>> information is required).
>
> Personally, i think that, at least for a library, an error should
> _only_ be communicated by return value. If more complex information
> is required, then the return value can be made more complex. I don't
> think i've ever used a library that communicates information via a
> pointer parameter.

Return value plus a pointer to additional information can certainly be
transformed into a struct containing both, though there’s an impact on
source code verbosity, object code size and performance.

For example if the extra information goes up to, say, 64 bytes, putting
it in a return value commits you to a 64-byte copy on every
return. However if it’s a pointer parameter, you only need to fill in
the fields relevant to the error that actually happened. In the happy
path, where there’s no error, that’s none of them.

--
https://www.greenend.org.uk/rjk/

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor