On 11/5/26 18:11, Anton Ertl wrote:
On Thu, Nov 05, 2026 at 04:23:16PM +0200, Elko Tchernev wrote:
The results are spectacular,the GP system is about 2x to 3x faster in 1.0.1.
than in 0.7.3., depending on problem.
Good to hear. If you want to submit a version of this program for the
appbench benchmark suite, I would love to include it.
I am rewriting it now and adding features, so not yet.
But in doing so I noticed another bug related to dynamic code generation
memory blocks.
From debugging it I understand that normally Gforth finalizes the old
block and then allocates or reuses another block. In the capture,
reserve_code_space` enters this rollover path and calls
`append_jump_previous` **before** the allocation/reuse step. It attempts
to append three bytes at `code_here=code_area+2097152`, where the old
block is already completely full. That write faults before the
next-block allocation.
GDB catches SIGSEGV:
...
__memcpy_ssse3
append_code(length=3)
append_jump
append_jump_previous
reserve_code_space
reserve_code_super
optimize_rewrite
compile_prim1
gforth_compile_range
gforth_engine2
...
At the fault:
...
code_area = 0x7fffb7000000
code_area_size = 2097152
code_here = 0x7fffb7200000
code_here - code_area = 2097152
last_jump = N_question_branch
restlength = 3
goto_len = 2
inst_index = -1 (inside append_jump_previous)
...
The pending dispatch is being appended at the first byte beyond the 2
MiB code block. The write faults at that point. The implicated engine
source is `..../gforth-1.0.1/engine/main.c`, particularly `append_jump`
around line 1484 and `reserve_code_space` around line 1521.
It does NOT happen every time the block boundary is crossed, I have not
measured how often. The workaround is to set --code-block-size= large
enough so it never needs to add more between successive MARKERs. But
this just hides the bug.
Greetings,
Elko