public inbox for xconq7@sourceware.org
 help / color / mirror / Atom feed
From: mskala@ansuz.sooke.bc.ca
To: xconq7 <xconq7@sources.redhat.com>, xconq-general@lists.sourceforge.net
Subject: How long was *that* there, I wonder?
Date: Sat, 04 Dec 2004 05:23:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.53.0412032356210.14151@opal.ansuz.sooke.bc.ca> (raw)

So, after a *lot* of debugging I managed to track down the source of a lot
of my problems with the IMF code.  You know what it was?

set_image_pixel_at.  It's a low-level function used throughout the IMF
code.  It basically just lets you index into bitmaps.  I've been seeing
calls to it all over the place, and writing some, and skipping over it in
the debugger, because I thought it was obvious what it did.  You call it
with coordinates and a parameter 1 to set a bit, and you call it with
coordinates and a parameter 0 to clear a bit.  Right?

Turns out that it actually does a bitwise OR.  So if you try to clear to 0
a bit that's already set to 1, nothing happens.  It appears that the code
prior to my work on it only ever used set_image_pixel_at when the input
happened to have been initialized to all zeroes, so this behaviour worked.
My code tries to use it to make changes in already-loaded bitmaps, and
then it fails.  It appears *intended* to replace the existing value
whatever it might be, and that's certainly the behaviour I would like for
my own use.  I changed it to do that (the function is local to imf.c, so I
think any unintended side effects of changing it will be easy to contain)
and all of a sudden a whole lot of my own code behaves a whole lot more
like what I expected.  Now I have to go through and un-do all the
elaborate changes I made while I was chasing this bug through other parts
of the code.  I think I'll include this patch as part of one of my bigger
ones rather than trying to submit it independently; although I think the
existing code is buggy, the bug doesn't show up except when my code
tickles it.

I'm not sure of the moral of the story - maybe "It's a good idea to trace
down into those low-level functions once in a while".  For such a simple
bug, this one soaked up a lot of debugging hours.
-- 
Matthew Skala
mskala@ansuz.sooke.bc.ca                    Embrace and defend.
http://ansuz.sooke.bc.ca/

             reply	other threads:[~2004-12-04  5:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-04  5:23 mskala [this message]
2004-12-04 12:40 ` Eric McDonald

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=Pine.LNX.4.53.0412032356210.14151@opal.ansuz.sooke.bc.ca \
    --to=mskala@ansuz.sooke.bc.ca \
    --cc=xconq-general@lists.sourceforge.net \
    --cc=xconq7@sources.redhat.com \
    /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 read-only IMAP folder(s) and NNTP newsgroup(s).