# Simple string pattern crashes kernel

Bug introduced in 6.0 or earlier and fixed in 10.1.0

The following code crashes my Mathematica kernel (v9, MacOS):

s = StringJoin[ConstantArray["65 H Isotropic = 27.4022 Anisotropy = 4.3297\n", 400]];
StringCases[s, (Except["\n"]..~~"\n")..];


Is this a known problem? Am I using string patterns in a wrong way?

• I can reproduce this in MMA9 och MMA10 on OS X. – C. E. Aug 18 '14 at 11:08
• No problem with version 10 on Windows 7 – Simon Woods Aug 18 '14 at 11:35
• Even if you are using string patterns incorrectly, you shouldn't get a kernel crash. – m_goldberg Aug 18 '14 at 11:46
• It crashes on Linux v8 as well. – Öskå Aug 18 '14 at 11:54
• Can reproduce on v10 Linux x64. – mfvonh Aug 18 '14 at 13:03

Is your StringCases expression intended to recover the 400 individual strings (without their terminating new-lines) that were joined to form s? If so, your pattern should have been

ss2 = StringCases[s, Except["\n"] ..];


although I suggest

ss3 = StringSplit[s, "\n"];


would have been a better way to do it.

Nevertheless, as I wrote in a comment to your question, what you evaluated should not have crashed the kernel, because, ideally, the kernel should never crash.

• The expression is a minimum working example derived from a more complicated string pattern used in parsing part of the output of a quantum chemistry program. The original input indeed had a header followed by multiple data lines followed by footer format. I was interested in one number in each line and a fast solution as I have to parse many of these files. Ideally I wanted a single pattern returning these numbers. The problem also seems a matter of input size: If you replace 400 by 100 in my example, evaluation goes through. – mrupp Aug 18 '14 at 14:10
• @mrupp. That it is a matter of input size is no surprise. Many kernel crashes are data size dependent. – m_goldberg Aug 18 '14 at 14:13