1. Invalid Page Fault and Safe.e

Hi All,

I seem to be having a problem similar to Kat's invalid page fault 
problem.  I have had a few of these from time to time with a Win32 
program I've been working on, and figured I'd try Safe.e also.  Here's 
the message I get: 

C:\EUPHORIA\Judith's IDE Version 0.10.3\machine.e:181 in procedure die() 

attempt to divide by 0 
    msg = {66'B',65'A',68'D',32' ',80'P',79'O',75'K',69'E',32' ',65'A',
68'D',68'D',82'R',69'E',83'S',83'S',33'!',33'!',33'!',33'!',32' ',55'7',
54'6',55'7',53'5',57'9',49'1',54'6',32' ',40'(',35'#',48'0',48'0',55'7',
53'5',50'2',48'0',48'0',67'C',41')'}
    t = 5.29
    i = 7

... called from C:\EUPHORIA\Judith's IDE Version 0.10.3\machine.e:278 in 
procedure poke()  
    a = 7675916
    v = 
{99'c',111'o',109'm',109'm',100'd',108'l',103'g',95'_',70'F',105'i',
110'n',100'd',82'R',101'e',112'p',108'l',97'a',99'c',101'e'}
    len = 19

... called from C:\EUPHORIA\Judith's IDE Version 0.10.3\tk_mem.e:97 in 
function acquire_mem()  
    pOwner = 0
    pData = 
{99'c',111'o',109'm',109'm',100'd',108'l',103'g',95'_',70'F',
105'i',110'n',100'd',82'R',101'e',112'p',108'l',97'a',99'c',101'e'}
    at = 7675916

... called from C:\EUPHORIA\Judith's IDE Version 0.10.3\Win32Lib.ew:681 


I don't see a reference to my program anywhere in here.  And what 
confuses me even more is that I get the same error when running ANY 
windows program with Safe.e.  I'm a newbie, so I'm probably missing 
something really obvious, but could someone give me a clue here?  I'm 
really stumped.

Thanks,

Virtual B

new topic     » topic index » view message » categorize

2. Re: Invalid Page Fault and Safe.e

Yer' right, you can't use safe.e with win32lib, ver.0.55.1.
It uses it's own 'stack' of memory which EU is unaware of.

This is really Derek's territory, but you could try the following patch to
tk_mem.e. It should work OK for small programs, at least.

...in function myAllocate(), you have the following lines, after which you
have to add the next !!

lAddr=c_func(xHeapAlloc,{pHeap,HEAP_ZERO_MEMORY,pSize})
if lAddr !=0 then
register_block(lAddr,16000)  --- ADD THIS LINE !!



All this does is register the initial win32lib 'stack' with EU, so
machine.e is aware of this memory block. However, if this stack 'grows'
larger than 16k., you'll have the same problem again.

new topic     » goto parent     » topic index » view message » categorize

3. Re: Invalid Page Fault and Safe.e

Virtual B. writes:
> This is not just a problem with my program either.  
> I've tried it with a lot of the programs that come with 
> Win32Lib and get the same results.  

Safe.e can't be used with Win32Lib.

A long time ago safe.e was able to catch subtle 
memory corruption bugs in Win32Lib-based programs,
but that is no longer possible for two reasons:

1. The implementors of Win32Lib decided not to use
Euphoria's allocate() and free() but instead to
develop their own heap routines using direct calls to 
WIN32 API routines. The reasons for this are not clear to me.

2. There are some places where Win32Lib
picks up the address of a block of memory from a call
to a C routine. They would have to call register_block()
and unregister_block() in safe.e to track this.
I'm not sure how much work would be involved here.
I've recently added a switch to safe.e that allows you
to not bother registering any external blocks, in exchange for
having a much weaker check on memory. In this case it 
only checks the "gutter" areas just before and just after
each allocated block for corruption. Addresses that are 
far removed from any allocated block would be 
assumed safe. However this requires that
allocate() and free() actually be used (point #1).

Regards,
   Rob Craig
   Rapid Deployment Software
   http://www.RapidEuphoria.com

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu