64bit app crash when using CHRB on certain strings

Hey all,

A heads up for you guys compiling for 64 bit apps…

If you do something like:

If t = chrb(10)+chrb(13) then
//
end if

And t has at least some high value characters in it, it will cause the app to crash. Use &u10+&u13 instead.

See:
<https://xojo.com/issue/41281>

My text in it has stuff like this:

The hex string in question is: FFFB 03FF FB01 FFFE 220D 0A55

Put this in the open event of an app and compile it for 64 bit. Then run it. BOOM!

  Dim t as string = DecodeHex("&hFFFB03FFFB01FFFE220D0A557365")
  
  If t = chrb(13)+chrb(10) Then
    MsgBox "YOW"
  Else
    MsgBox "No Crash"
  End if

I dont know if it is related, but I also SOMETIMES find problems when loading a stringConstant array containing certain glyphs, like ellypsis.
In my case, the workaround is to replace split, nthField etc with spliB, nthFieldB etc.
For instance:
Dynamic constant (mConst) = Show…,Apples,Lemons,Butterflies,Papers
dim s() as string = split(mConst, “,”)
for i as integer = 0 to ubound.s
popupmenu1.addrow s(i)
next

The first row SOMETIMES shows “Show(+ a weird char)”, and the following rows too get weird, for instance:
s, apple
s, emons
etc.
So I guess s() chocks with ellypsis and maybe other chars.

But using splitB things work OK.
Same problem when parsing some text from the net.

But no crash.

[quote=222420:@Jon Ogden] Dim t as string = DecodeHex("&hFFFB03FFFB01FFFE220D0A557365")

If t = chrb(13)+chrb(10) Then
MsgBox “YOW”
Else
MsgBox “No Crash”
End if[/quote]

Get rid of the &h part
Its not hex data
That may be contribute to why you’re having issues

[quote=222444:@Norman Palardy]Get rid of the &h part
Its not hex data
That may be contribute to why you’re having issues[/quote]

You are mistaking my example for the real world. The string data in question is being read over a TCP socket. The actual string values that come in initially cause this crash. I had to use the encodehex function to generate that string in an example. Trust me - the hex representation of the string data being read is indeed what I showed you. I can take a screen shot of it if you like to prove my point.

The example generates the specific data that I get in the app in the real application. My actual code doesn’t use the encodehex at all.

And I got your notes in the bug report too. Doesn’t matter. Using the chrb functions should not cause a hard crash of the app.

[quote=222546:@Jon Ogden]You are mistaking my example for the real world. The string data in question is being read over a TCP socket. The actual string values that come in initially cause this crash. I had to use the encodehex function to generate that string in an example. Trust me - the hex representation of the string data being read is indeed what I showed you. I can take a screen shot of it if you like to prove my point.
[/quote]
Including the leading & ?
Decode hex should barf on that
That is not valid hex encoded data in any way

[quote=222546:@Jon Ogden]The example generates the specific data that I get in the app in the real application. My actual code doesn’t use the encodehex at all.
And I got your notes in the bug report too. Doesn’t matter. Using the chrb functions should not cause a hard crash of the app.[/quote]

You’ll note I didn’t mark it as NOT A BUG
I DID say “heres something that DOES work”

Agreed. I found a workaround as well. But the returned hex data in my example project is exactly the same as the data I get in the real world from my real world network switch when I first make a connection.

Yeah, I just removed the &h from the string in the code. No difference. Still crash bang boom!

In my actual app code, I don’t use DecodeHex. I just had that to try to recreate the received string.