The weirdest thing to-date!

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
dh

The weirdest thing to-date!

Post by dh »

I just finished kPrint and just added a function to clear the current line (wraps to top like Clicker32). Now get this: the BOCHS BIOS panics and kills the program for _NO REASON_. In the log it complains about a "unknown" command. Here is the gotcha', it quits in real mode. WTF? I don't know what's up, but when I disable the clear-current-line, it works fine. Just _calling_ it is fatal. I tried increasing inital stack space, but this didn't help. I'm using just the everyday kPutChar and For stuff. (everything goes to kPutChar for the wondering). Code is avilable on request.

Cheers, DH.

PS. I'm weirded out ;P
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

Re:The weirdest thing to-date!

Post by bubach »

requesting code... ;)
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:The weirdest thing to-date!

Post by Solar »

Dragon_Hilord wrote:Now get this: the BOCHS BIOS panics and kills the program for _NO REASON_.
None that you are aware of.

Contrary to popular belief, computers still are deterministic. If you can't see a reason for something, you are not in posession of all the facts.

Like, your source code. ;)
Every good solution is obvious once you've found it.
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:The weirdest thing to-date!

Post by Pype.Clicker »

i'd suspect a non-terminating loop here that would be clearing everything, including your code.

here again, activating "trace-on" might help figuring out what occured before the crash...
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:The weirdest thing to-date!

Post by Candy »

Solar wrote:
Dragon_Hilord wrote:Now get this: the BOCHS BIOS panics and kills the program for _NO REASON_.
None that you are aware of.

Contrary to popular belief, computers still are deterministic. If you can't see a reason for something, you are not in posession of all the facts.

Like, your source code. ;)

Computers are not fully deterministic, but each component in itself is deterministic. IE, if you do A, you get B.

Bochs is however fully deterministic in that if a timer interrupt occured at exactly cycle X the last time, it will do that too this time. The sole few undeterministic events are keypresses etc. If you don't use them, it should give the same result / crash each time.
dh

Re:The weirdest thing to-date!

Post by dh »

I will put the code up on sourceforge soon (for ease).
There are two things in the log of interest:
1) Unknown opcode
2) FDD not avilable
3) Some unnamed exception.

I'll try to have the code up withen the week ;D
User avatar
bubach
Member
Member
Posts: 1223
Joined: Sat Oct 23, 2004 11:00 pm
Location: Sweden
Contact:

Re:The weirdest thing to-date!

Post by bubach »

OT: Add http:// at the front of your link to "SJ High School!"
"Simplicity is the ultimate sophistication."
http://bos.asmhackers.net/ - GitHub
dh

Re:The weirdest thing to-date!

Post by dh »

I'm gonna put some code in from memory (psudo code) to help give the idea:

Code: Select all

File: Screen.c
unsigned int _X;
unsigned int _Y;

kPutChar(y, x, color, character);
kPrint(fmt* ...)
{
   loop through fmt{
   if char, call _PrintChar(char)
   if int, call _PrintInt(int)
   if str, call _PrintStr(str)
   if hexint, call _PrintIntHex(int)
   Allelse: _PrintChar(char)
   }
}

_CheckScreen()
{
   is _X <= MAXWIDTH?
      yes: _X=0
             _Y++
   is _Y <= MAXHEIGHT?
      yes: _X=0
             _Y=0
   is _X = 0?
      yes: ClearLine(_Y)  <--Remove this and all runs honkey-dorey!
}

_PrintChar(char)
{
   kputchar(_Y, _X, char)
   _X++
   _CheckScreen()
}

_PrintInt(int)
{
   Process to character
   _PrintChar(intcharacter)
   _CheckScreen()  <-- There is probably more code I don't remember
}
_PrintIntHex(int)
   Process to character
   _PrintChar(inthexcharacter)
   _CheckScreen()
}

_PrintStr(str)
{
   for each character in string
      _PrintChar(char)
}

_ClearLine(line)
{
   int i
   for (i=0;i<MAXWIDTH;i++)
      kPutChar(line, i, 0xFFF, ' ')  <-- 0xFFF universial color for normal color
}
Cheers, DH. Hope this helps some (this is the VERY basic system that is used before a console module is created and loaded, which is used forever after).

[edit]I was just sifting through the quicklinkz and found this:
running in bogus memory: you sent your code pointer (eip) to some uninitialized memory area. This means either you followed a null/uninitialized pointer, or damaged the return address of your stackframe. Make your code more clean, test pointers before you follow them, initialize every pointer, especially those who are on the stack, and enable -Wall.
I _WAS_ having this problem, then changed the code (increased the stack to 32k (see barebones)). Strangly enough, when I changed the code in _ClearLine, and reverted to 16k stack, it still crashed with a different result. *grumble* I'm gonna _HAVE_ to go through ALL my source files, attach the GPL notice, and setup a sourcefoege account and project before I can have the code up for you all *grumble*.
[/edit]
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:The weirdest thing to-date!

Post by Candy »

Dragon_Hilord wrote: I will put the code up on sourceforge soon (for ease).
There are two things in the log of interest:
1) Unknown opcode
2) FDD not avilable
3) Some unnamed exception.

I'll try to have the code up withen the week ;D
Might there be a problem with counting?
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:The weirdest thing to-date!

Post by Pype.Clicker »

i see something potentially harmfull ... "clearline" calls "check screen" and "checkscreen" calls printline ...
hmm hmm ...

not 100% sure but could that lead to stack overflow ?
dh

Re:The weirdest thing to-date!

Post by dh »

NOW THAT COULD BE IT! I don't remember if kPrintChar calls CheckScreen or not. I'll check asap! Thanks pype ;D

cheers, DH.

PS. I'm gonna download the latest clicker ;D
DruG5t0r3

Re:The weirdest thing to-date!

Post by DruG5t0r3 »

Here is my kprintf code...

only supports %u and %x up to now...but it does what I need.

Code: Select all

int kprintf(char *message, ...)
{
        int i=0;
        char buffer[10];
        char *buffer_ptr;

        va_list data;
        va_start(data, message);

        while (*message) {
                if (*message == '%')
                {
                        unsigned int num = va_arg(data, unsigned int);
                        message++;
                        switch(*message)
                        {
                                case 'u':
                                        buffer_ptr = buffer + 9;
                                        *buffer_ptr = '\0';
                                        do
                                        {
                                                unsigned long temp;
                                                temp = (unsigned long)num % 10;
                                                buffer_ptr--;
                                                *buffer_ptr = temp + '0';
                                                num = (unsigned long)num / 10;
                                        }
                                        while(num != 0);

                                        while (*buffer_ptr)
                                                putch(*buffer_ptr++);

                                        break;
                                case 'x':
                                        buffer_ptr = buffer + 9;
                                        *buffer_ptr = '\0';
                                        do
                                        {
                                                unsigned long temp;
                                                temp = (unsigned long)num % 16;
                                                buffer_ptr--;
                                                if (temp < 10)
                                                        *buffer_ptr = temp + '0';
                                                else
                                                        *buffer_ptr = temp - 10 + 'a';
                                                num = (unsigned long)num / 16;
                                        }
                                        while(num != 0);
                                        buffer_ptr--; *buffer_ptr = 'x';
                                        buffer_ptr--; *buffer_ptr = '0';

                                        while (*buffer_ptr)
                                                putch(*buffer_ptr++);

                        }
                        message++;
                }
                else
                        putch(*message++);
        }

        va_end(data)

        return 0;
}
dh

Re:The weirdest thing to-date!

Post by dh »

May the bells ring and banners fly! Fixed at last and fully operational! ;D Thank go out to all who helped. (FYI, it was my kScreenLocate command, called by _ClearLine, was calling _ScreenCheck, and so on.)

Note to n00bs: Read your code before you come to the forum, it's probably something obvious, like this :D

Cheers, DH.
Post Reply