Invalid page fault in Windows98 
Author Message
 Invalid page fault in Windows98


Quote:
> I'm porting a program from straight dos c to a windows console app.
> I've declared almost all of the program as extern C and had to make some
minor
> changes here and there to make most of it work.

> My problem now is on calls to strlwr I was getting invalid page faults.
I
> looked in MSDN and strlwr is not listed _strlwr is, and it makes the
correct
> substitutions to get that, so I decided I'd substitute my own strlwr
function
> in case the compiler was compiling it for wide chars.  It's a very simple
> function and everything runs to the same point as before (leading me to
think
> stack / pointer problem), if I go into debug from here (or run in the
> de{*filter*}) it brings up the code at the proper place all vars / registers
etc.
> look fine and then it will complete while in the de{*filter*}.

_strlwr is not an ANSI function (hence that leading underscore), so the
question is slightly off-topic.

It seems like you have a Heisenbug (the act of observing the problem using
the de{*filter*} makes the problem 'go away'). This, and the invalid page
fault, pretty much nail it down to a bug in the way you are using a pointer
or an array.

Unless you can post a complete program (shorn of extraneous detail but
still exhibiting the problem) there is little more help I can think of to
give you. Check your pointers, check your array bounds, check your loop
termination conditions.

If I were to write an implementation of strlwr(), I would do it something
like this (I presume you want strlwr() to set a string to lower case but,
since it's not in the standard, I'm only guessing - maybe it counts your
elephant collection) :

#include <ctype.h>

char * my_strlwr(char *s)
{
        char *t;

        for(t = s; *s; s++)
        {
                if(isupper(*s))
                {
                        *s = tolower(*s);
                }
        }
        return t;

Quote:
}

This will work provided s is correctly zero-terminated.

++luck;
--
Richard H

#include "sig.h"



Sun, 05 Aug 2001 03:00:00 GMT  
 Invalid page fault in Windows98

Quote:

> My problem now is on calls to strlwr I was getting invalid page faults.  

I would check that the buffer being passed to strlwr is in fact big
enough for the string. As a test I would add a fudge factor to your
string buffers as this will probably fix the problem. For example:

  #define FUDGE_FACTOR  100

  char string_buffer[200 + FUDGE_FACTOR];

Quote:
> I
> looked in MSDN and strlwr is not listed _strlwr is, and it makes the correct
> substitutions to get that, so I decided I'd substitute my own strlwr function
> in case the compiler was compiling it for wide chars.  

If your compiler switch settings are correct this will not happen. If
you
use the wizard to create a new project the IDE will most likely have got
the compiler setting correct.

Quote:
> It's a very simple
> function and everything runs to the same point as before (leading me to think
> stack / pointer problem), if I go into debug from here (or run in the
> de{*filter*}) it brings up the code at the proper place all vars / registers etc.
> look fine and then it will complete while in the de{*filter*}.

From what you describe this must be a stack problem. I think that what
is
happening is in the de{*filter*} the page fault trapped by the de{*filter*} and
when
you ask it to continue it just ignores the fault and by luck the works.
Outside
the de{*filter*} the operating system gets the fault and kills the program.

The last time I got a page fault it was a bug with a infinte loop that
called
a function recursively and this action blew the stack.

Quote:
> Any ideas,

Check for places where the stack could be getting corrupted.

Jussi Jumppanen
Author of: Zeus for Windows, Win32 (Brief, WordStar, Emacs) Text Editor
"The C/C++, Java, Pascal, Cobol, fortran programmers text editor"
Home Page: http://www.*-*-*.com/



Mon, 06 Aug 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Invalid Page Fault?

2. Invalid page faults when accessing large arrays

3. caused an invalid page fault in module ...

4. Invalid Page fault in module MSJT3032.DLL

5. Invalid page fault

6. Invalid page fault

7. invalid page fault

8. Invalid Page Fault in Release mode with ML compiler option

9. invalid page fault ...

10. MSDEV caused an invalid page fault in Module SSSCC.DLL After Install SP2

11. invalid page fault when I exit my program

12. Help - receiving invalid page fault in kernel32.dll

 

 
Powered by phpBB® Forum Software