Page 1 of 1

Calling methods on a temporary string uses previous string

Posted: Tue Sep 16, 2025 8:52 pm
by m8f
Steps to reproduce:
Load this code as zscript.zs lump and start any Doom map with a zombie:

Code: Select all

version 4.14

class TestZombie : Zombieman replaces Zombieman
{
  override void BeginPlay()
  {
    //Console.Printf("I'll cause a VM abort".makeLower());

    Console.Printf("---------");
    Console.Printf("I'M OLD");
    Console.Printf("I'm new".makeLower());
  }
}
Code loads without errors and warnings (with `developer 2`).

Expected result:

Code: Select all

---------
I'M OLD                                                                                                             
i'm new
OR a syntax error on loading?

Actual result:

Code: Select all

---------
I'M OLD                                                                                                             
i'm old
Note: the first Console.Printf, if uncommented, causes a VM abort: `VM execution aborted: tried to read from address zero. In function parameter "self"`

Reproduces on GZDoom 4.14 and the latest master (commit f892a750b "Silence integer division warning").
Reproduces on Manjaro Linux, Linux 6.6.103-3-MANJARO on x86_64, and Debian GNU/Linux 13 (trixie), Linux 6.12.34+rpt-rpi-v8 on aarch64.

Re: Calling methods on a temporary string uses previous string

Posted: Wed Sep 17, 2025 10:43 am
by phantombeta
This sounds like it's somehow getting the wrong register for the function call...
AFAIK string literals (i.e., constants) have to be copied over from a string constant to a string register to have a function called on them, something must be going wrong in that process...

Re: Calling methods on a temporary string uses previous string

Posted: Mon Sep 22, 2025 5:54 pm
by Jay0
does it reproduce with the JIT off?

Re: Calling methods on a temporary string uses previous string

Posted: Mon Sep 22, 2025 7:28 pm
by m8f
Yes, it reproduces with both on and off:

Code: Select all

---------
I'M OLD
i'm old
]vm_jit
"vm_jit" is "false" (default: "true")

Code: Select all

---------
I'M OLD
i'm old
]vm_jit
"vm_jit" is "true" (default: "true")