# Bizarre error messages when monitoring random integers

I am doing

tbl = {};
Monitor[
Do[AppendTo[tbl, RandomInteger[{1, 100000}, 2]], 100000],
Length[tbl]
]


(well in fact I am doing something less boring but what I want to ask about happens here too)

Every now and then the following message is generated:

RandomInteger::array: The array dimensions 2 given in position 2 of
RandomInteger[{1,100000},2] should be a list of non-negative machine-sized integers
giving the dimensions for the result.


What is wrong?

• Now such message when I execute it in version 11.3 on macOS. Try to restart the kernel. Btw., this use of AppendTo slows down things needlessly: A randomm table of that size can be obtained with RandomInteger[{1, 100000}, {100000, 2}]; in a 20000th part of the time. – Henrik Schumacher Aug 6 '18 at 12:52
• @HenrikSchumacher Mine is 11.0.1 on Windows 10. The reason I use AppendTo is that what I actually want to do requires some time at each step, so I would like to place a ListPlot as the second argument of Monitor, to watch the picture while it gradually emerges. – მამუკა ჯიბლაძე Aug 6 '18 at 13:10
• Run the code 5 times on a fresh kernel, and no error message. Tested on 10.4.1 for Microsoft Windows (64-bit). – AccidentalFourierTransform Aug 6 '18 at 15:11
• Error Do::itform in MMAv9. – Hector Aug 6 '18 at 18:17
• It was a perfectly good question (albeit with imperfect info). The key was use of Monitor, which interacts with the kernel using a thread. THere was a bug, now fixed, in (mis)handling of a signal that hits at an inopportune time; there was cross-talk between threads and the Do iterator was getting messed up. If you provide full code to replicate we can try testing in a current kernel to make sure we fully made it go splat (the bug, I mean, not your code). Can do this either in this MSE question or through Tech Support. – Daniel Lichtblau Oct 18 '18 at 21:51