allocate_string() "bug"
- Posted by Daniel Berstein <danielberstein at USA.NET> Apr 07, 1998
- 895 views
Quote from RDS "Programming Tips" page: [begin quote] Aug 28/97: Be very careful when you use direct memory operations such as poke(), mem_copy(), and mem_set(). Euphoria does no checking on the memory addresses that you use with these routines. If you miscalculate by even a single byte, you can crash your program, or your whole system. In many cases you will quietly corrupt an internal data structure needed by Euphoria, and for a while your program may appear to work fine, but later you may get strange "Causeway" errors, perhaps after a trivial change to your code, or after you bind your program. The blocks of memory that you get from allocate() typically have critical internal information needed by the interpreter stored just before and just after them. This type of bug can be very hard to track down. The best approach is to avoid the bug in the first place by doing your arithmetic carefully and by paying close attention to "boundary conditions". Where will the first byte be stored? Where will the last byte be stored? [quote end] .... as you can see we all make mistakes, even RDS. Regards, Daniel Berstein.