edbrowse-dev - development list for edbrowse
 help / color / mirror / Atom feed
From: Adam Thompson <arthompson1990@gmail.com>
To: Karl Dahlke <eklhad@comcast.net>
Cc: Edbrowse-dev@lists.the-brannons.com
Subject: Re: [Edbrowse-dev] if then else
Date: Tue, 22 Apr 2014 17:52:04 +0100	[thread overview]
Message-ID: <20140422165204.GF23557@toaster.adamthompson.me.uk> (raw)
In-Reply-To: <20140322123426.eklhad@comcast.net>

[-- Attachment #1: Type: text/plain, Size: 2605 bytes --]

On Tue, Apr 22, 2014 at 12:34:26PM +0000, Karl Dahlke wrote:
> Ok, my last push changed over 400 lines of code.
> Really?
> Yes, and all bug fixes; some serious,
> serious enough to cause a segfault.

Wow.

> What happened?
> 
> My first mistake was in jsrt.
> I didn't include any tests for the URL class.
> That class is very special and very complicated, over a thousand lines of code.
> With no regression tests, bugs could creep in and nobody would know.
> And they did.

Ah.  Are there any other missing tests from jsrt while we're here?

> My latest push adds tests for this class, so this won't happen again.
> See jsrt line 536.

Good to hear, when I've not got large amounts of university work to do I'll have a look.

> I'm not going to describe all the bugs, but here is a funny one.
> We had, for a long time, code like this:
> 
> if(condition)
> do this
> else
> do that
> 
> But no error legs in js was leading to nulls and segfaults,
> so we put in error legs all over the place.
> This we needed to do, and thanks to everyone for your help.
> There were so many, the process was rather mechanical,
> and understandably so.
> Just get er done.
> Thus the above code became:
> 
> if(condition)
> if(do this and it fails) {
> js fail
> return
> }
> else
> if(do that and it fails) {
> js fail
> return
> }
> 
> If you've studied formal language theory and compilers,
> then you know this is the region of the C grammar that is ambiguous.
> But the compiler doesn't tell you that,
> it just picks a derivation and marches on.

Yep.

> Which one?
> Not the one we expect.

Yeah, it certainly isn't imediately obvious from reading the code what happens 
here,and I suspect I missed these when reviewing... sorry.

> I changed the code as below and several bugs went away.
> 
> if(condition) {
> if(do this and it fails) {
> js fail
> return
> }
> } else {
> if(do that and it fails) {
> js fail
> return
> }
> }
> 
> There were quite a few blocks like this.

Yeah I'm not surprised and well done for figuring out what the logic *should* 
have been.

> So there you go - bitten by the if else ambiguity of C.

Yep and by the sounds of it quite badly.
I'm now wondering if there are any other bugs of this type waiting to be 
discovered.

> There were other bugs too, dealing with string allocation
> and a malformed url constructor.
> I think they are fixed now; jsrt passes anyways.
> I'm glad I cleaned all this up before release 3.5.1.

So am I, again well done for fixing these.

Cheers,
Adam.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

      reply	other threads:[~2014-04-22 16:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-22 12:34 Karl Dahlke
2014-04-22 16:52 ` Adam Thompson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140422165204.GF23557@toaster.adamthompson.me.uk \
    --to=arthompson1990@gmail.com \
    --cc=Edbrowse-dev@lists.the-brannons.com \
    --cc=eklhad@comcast.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).