Skip to content

AccessViolationException with FRead() #686

@cpyrgas

Description

@cpyrgas

FRead() produces an AccessViolationException, when the string argument is passed with the @ operator and /vo7+ is enabled. When the REF keyword is used instead of "@", then the function works correctly.

// /vo7+
FUNCTION Start() AS VOID
LOCAL cFileName AS STRING
LOCAL hHandle AS PTR
LOCAL cText AS STRING
cFilename := "c:\test\abc.txt"

System.IO.File.WriteAllText(cFileName , "ABCDE1234567890")
hHandle := FOpen(cFileName)
FRead(hHandle , REF cText , 5) // ABCDE, OK
? cText
FRead(hHandle , @cText , 5) // System.AccessViolationException
? cText
FClose(hHandle)

System.AccessViolationException
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Callstack : 
String XSharp.__Usual.ToString()() 
static String XSharp.__Usual.op_Implicit(XSharp.__Usual u)() 
static String XSharp.RT.Functions.AsString(XSharp.__Usual uValue)() 
static System.Void XSharp.RT.Functions.QOut(XSharp.__Usual uValueList)() 

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions