Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Gforth strange bug with SAVECROSS

4 views
Skip to first unread message

David Kuehling

unread,
Feb 8, 2012, 6:36:54 PM2/8/12
to
Hi,

I'm still tinkering around with Gforth-EC, and think I've hit a bug with
Gforth's cross-compiler, in SAVECROSS.

Specifically this code causes crashes for me and the bug is easily spotted:

>rom dictionary >rmem @ there
s" rom" X $has? IF dictionary >rstart @ - THEN
r@ ~~ write-file throw \ write image

For romless gforth-ec builds, it writes 'THERE' number of bytes into the
image file. However, it doesn't start at target address 0, but at
the dictionary region's start addres (corresponding to whatever was
configured via SETVALUE KERNEL-START resp. REGION DICTIONARY) .

Even the 8086 gforth-ec build has the problem (but luckily doesn't
crash):

DP is $37FE at the end of compilation, so it writes $37FE bytes to the
.com kernel. But the first 256 bytes are not part of the dictionary
region, so it writes addresses 256...256+$37FE to the image, resulting
in 256 zeros being written at the end (easily verified via hexdump -C
gf8086.com).

Now, for my LM32/milkymist GForth-EC build, KERNEL-START is $40000000,
now it really attempts to write $40006380 bytes to the image, suffering
a segfault (because the dictionary only has 256KB).

The fix /looks/ easy, just remove the If-statement:

>rom dictionary >rmem @ there
dictionary >rstart @ -
r@ ~~ write-file throw \ write image

now the 8086 and lm32 gforth-ec images build correctly. However, as a
side effect the normal non-ec gforth kernel build fails :

./BUILD-FROM-SCRATCH
[..]
GFORTH="./preforth -p ".:~+:."" ./gfgen -fast
gforth: ./main.c:364: branch_targets: Assertion `i*sizeof(Cell) < size' failed.
./preforth: line 31: 19127 Aborted $ENGINE --die-on-signal -i kernl64l.fi $path1 $path2 exboot.fs startup.fs "$@"

I'm scratching my head. Any ideas what's the right way to fix that?

cheers,

David
--
GnuPG public key: http://dvdkhlng.users.sourceforge.net/dk.gpg
Fingerprint: B17A DC95 D293 657B 4205 D016 7DEF 5323 C174 7D40
0 new messages