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?

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

1 Answer 1


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.

  • $\begingroup$ 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. $\endgroup$
    – mrupp
    Commented Aug 18, 2014 at 14:10
  • 2
    $\begingroup$ @mrupp. That it is a matter of input size is no surprise. Many kernel crashes are data size dependent. $\endgroup$
    – m_goldberg
    Commented Aug 18, 2014 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.