Enforcer hits ?

Everything else that doesn't fall into one of the other PB categories.
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Enforcer hits ?

Post by Flype »

When i do this :

Code: Select all

a$ = "pure"
PokeS(@a$,"purebasic")
Debug a$
Here, i write illegaly to memory.

Does exists a tool that can monitor illegal writes to memory ?
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
Trond
Always Here
Always Here
Posts: 7446
Joined: Mon Sep 22, 2003 6:45 pm
Location: Norway

Post by Trond »

The debugger will complain if you write outside the allocated string buffer.
freak
PureBasic Team
PureBasic Team
Posts: 5948
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

Only if the memory area after your allocated buffer is marked as invalid or readonly.
Usually small buffer overflows are not catched, because the remainder of the
memory page where your buffer is located is not marked invalid, and therefore
produces no error when written to.
quidquid Latine dictum sit altum videtur
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

Buffer overrides :P
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

@freak
thanx for the explanation.
how to declare such memory areas as invalid ?

and a tool ? a microsoft one perhaps...
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
Fred
Administrator
Administrator
Posts: 18351
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

A good way on Windows is to use HeapValidate() to help tracking down such bug. It's not easy if the overflow is only 1 byte for example, as Windows always reserve by block of 16 bytes. So writting after won't produce anything wrong.
User avatar
Flype
Addict
Addict
Posts: 1542
Joined: Tue Jul 22, 2003 5:02 pm
Location: In a long distant galaxy

Post by Flype »

fred, let's have fun :

( from AWEAR, french forum )

Code: Select all

PokeS(@"true", PeekS(@"false"))
x$ = "true"
Debug x$
Debug "true"
I don't think it's a bug, it seems normal but surprising me first time.
:wink:
No programming language is perfect. There is not even a single best language.
There are only languages well suited or perhaps poorly suited for particular purposes. Herbert Mayer
Fred
Administrator
Administrator
Posts: 18351
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

you writting directly in the data section, no wonder ;)
Post Reply