TextInputStream.ReadAll Mystery Crash

I have an app with this code fragment in it:

dim tis as textinputstream
dim FileChunkStr as string

tis=TextInputStream.Open(filespec) 'filespec is the folder item being read

if tis=Nil then
end if

FileChunkStr = tis.ReadAll

When I run the app (in the IDE or as a built app), it “Quits Unexpectedly” on the tis.ReadAll, saying:

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 com.xojo.XojoFramework 0x05e257b4 0x5da7000 + 518068
1 com.xojo.XojoFramework 0x05e33a3c 0x5da7000 + 576060
2 com.xojo.XojoFramework 0x05efaa9a TextInputStreamRead + 93
3 com.xojo.XojoFramework 0x05efb61b TextInputStreamReadAll + 77
4 com.mckernon.lightwright6 0x000be8e1 TextInputStream.ReadAll%s%oo + 74

The mystery is, if I put this same code into a small sample app, it doesn’t crash. Both apps are reading the same file, and the file exists and is readable.

This is using Xojo 2015r2.

Does anyone have any thoughts on what might cause .ReadAll to crash like this?


Do you do it this way?

if filespec <> nil and filespec.Exists then tis=TextInputStream.Open(filespec) .... end if

If I had to guess, I would say that your file is very large and can’t fit within the memory available.

Joe, you’re right! It turns out a loop error had generated a database about 100,000 times larger than usual. I’m surprised it didn’t raise an exception, but I guess somethings are just too catastrophic to catch. Thanks!