ID:2881022
 
Resolved
Byondapi: Byond_ReadPointer() and Byond_WritePointer() didn't function as intended.
BYOND Version:515.1609
Operating System:Windows 10 Pro 64-bit
Web Browser:Firefox 115.0
Applies to:Dream Daemon
Status: Resolved (515.1610)

This issue has been resolved.
Descriptive Problem Summary:
Byond_ReadPointer and Byond_WritePointer seem to be non-functional, and always throw a runtime error. Pointers through FFI end up as type 0x3C with a value of their id, but passing these to Byond_ReadPointer or Byond_WritePointer results in runtime error: bad pointer.

Numbered Steps to Reproduce Problem:

1. Send pointer type through call_ext
2. Observe CByondValue has type 0x3C and data (the pointer ID)
3. Try to call Byond_ReadPointer or Byond_WritePointer
4. Observe runtime error: bad pointer and Byond_LastError returning "null"

Code Snippet (if applicable) to Reproduce Problem:
/proc/ptr_bug()
var/a=3, b=4
var/p = &a
var/p2 = &a
world.log << *p // same as world << a
*p = 5 // same as a = 5
world.log << *p
// byond:test_ptr calls Byond_WritePointer
var/ret = call_ext("fakelib.dll", "byond:test_ptr")(p2) // runtime error: bad pointer

// (if test_ptr is stubbed out we can check
world.log << "number: [*p]"
world.log << "ret: [ret]"


Expected Results:

Byond_WritePointer and Byond_ReadPointer would allow writing and reading through pointers

Actual Results:

runtime error: bad pointer
Byond_LastError(): "null"

Does the problem occur:
Every time? Or how often? Always
In other games? N/A
In other user accounts? ?
On other computers? ?

When does the problem NOT occur?
Workarounds:

Haven't been able to find a workaround yet.



Lummox JR resolved issue with message:
Byondapi: Byond_ReadPointer() and Byond_WritePointer() didn't function as intended.