To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.legosOpen lugnet.robotics.rcx.legos in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / legOS / 1211
1210  |  1212
Subject: 
Strange crash (and possible fix)
Newsgroups: 
lugnet.robotics.rcx.legos
Date: 
Fri, 14 Jul 2000 04:34:11 GMT
Viewed: 
1152 times
  
I had a strange experience today. My program likes to crash a lot. I
accept this as a fact of life now; part of it is the difficulty in
debugging it, and part seems to be the beta-ness of legOS. However, today,
I tracked down one particularly evil bug, and I really don't understand it
at all.

Before, my program would crash roughly 50% of the time right at startup.
I'd make some irrelevant changes and it'd be happy the next time.. maybe.
Then I got the compiler working under LinuxPPC, and started playing around
with LNP. I made some neat debug functions that let me see what was going
on better. I tracked these semi-random crashes down to three lines of
code.

  gNavInfo.x = 0;
  gNavInfo.y = 0;
  gNavInfo.dir = 0;

gNavInfo was defined as:

struct {
  long x, y;
  long dir;
} gNavInfo;

When the program did its weird random crashes, it was at those three
lines. I'm certain of it. What I don't know is WHY? I changed the
definition into a typedef and made gNavInfo a pointer to that struct. Then
I use malloc to get a chunk for storage. Voila, my crashes seem to have
gone away. The only thing I can think of is if something would break if
the longs weren't aligned on a four-byte boundary. My "irrelevant" changes
could possibly fix things so that they were on a boundary, on break things
so that they weren't. But I don't see why that would crash. Does anybody
have any insight?

Btw, LNP is awesome!

--
  "Do not go gentle into that good night.
   Rage, rage against the dying of the light."
                    - Dylan Thomas
Mike Ash - <http://www.mikeash.com/>, <mailto:mail@mikeash.com>



Message has 1 Reply:
  Re: Strange crash (and possible fix)
 
Mike- I wish I knew. I have frequently seen the same kinds of "random" changes produce better results. For example, I had one piece of code that used a switch statement- 19 statements in all. I added a 20th and poof... it froze. I have no idea what (...) (24 years ago, 14-Jul-00, to lugnet.robotics.rcx.legos)

3 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR