7
$\begingroup$

Reported to WRI. CASE:4330461


V 12 on windows 10 64 bit. Note: This problem do not show up in V 11.3. Only in V12.

For the last 2 hrs, I've been trying to zoom into why V12 kernel crash when calling Integrate on this problem.

This is part of much larger test suite. When running this particular simple integration, kernel crash and only get a beep sound with no messages.

I tried to make the MWE as simple as possible.

First will show the basic MWE where it crash, then show simple changes to make the crash go away. In all these MWE below, I always start from fresh kernel.

To run this MWE, the integrate problem must be read from a file. The file has one line in it. It is plain text file. I'll also put a link at the end to the file also. also put a link to small zip file which has the notebook and the input file all in same folder to make it easier.

SetDirectory[NotebookDirectory[]];
ClearAll["Global`*"];
test1[nameOfTestFile_] := Module[{n, res, lst},(*crash*)
   lst = ReadList[nameOfTestFile];
   lst = DeleteCases[lst, Null];
   Do[
    Print["Before calling Integrate"];
    res = AbsoluteTiming[TimeConstrained[Integrate[lst[[n, 1]], lst[[n, 2]]], 60*3]]
    ,
    {n, 1, Length@lst}  
    ]
   ];

Do[
 test1["Timofeev_Problems.m"];
 Print["Finished"]
 , {myCounter, 1, 1}
 ]

 (*** crash ***)

enter image description here

Only Timofeev_Problems.m file is needed file in same folder as the notebook to run the above MWE. The file contains just one line

   {Sin[x]/(1 + Sin[x]), x, 2, x + Cos[x]/(1 + Sin[x])}

Here is a link to the above file just in case Timofeev_Problems.m

Here is a link to zip file which contains the notebook and the input file all in one folder strage_bug.zip

Now, after getting the above crash, the weirdness really starts.

The crash goes away by doing any of these simple things (which all makes no sense why doing them eliminates the crash).

Removing a print statement inside test1 eliminates the crash

Removing the Print Before inside the test1, the crash goes away. Like this

SetDirectory[NotebookDirectory[]];
ClearAll["Global`*"];
test1[nameOfTestFile_] := Module[{n, res, lst},(*crash*)
   lst = ReadList[nameOfTestFile];
   lst = DeleteCases[lst, Null];
   Do[
    res = AbsoluteTiming[ TimeConstrained[Integrate[lst[[n, 1]], lst[[n, 2]]], 60*3]]
    ,
    {n, 1, Length@lst}  
    ]
   ];

Do[
 test1["Timofeev_Problems.m"];
 Print["Finished"]
 , {myCounter, 1, 1}
 ]

 (*no crash*)

Removing the print statement in the loop calling test1 eliminate crash

SetDirectory[NotebookDirectory[]];
ClearAll["Global`*"];
test1[nameOfTestFile_] := Module[{n, res, lst},(*crash*)
   lst = ReadList[nameOfTestFile];
   lst = DeleteCases[lst, Null];
   Do[
    Print["Before calling Integrate"];
    res = AbsoluteTiming[TimeConstrained[Integrate[lst[[n, 1]], lst[[n, 2]]], 60*3]]
    ,
    {n, 1, Length@lst}  
    ]
   ];

Do[
 test1["Timofeev_Problems.m"]
 , {myCounter, 1, 1}
 ]

 (*no crash*)

Keeping all print statements but removing AbsoluteTiming eliminates the crash

SetDirectory[NotebookDirectory[]];
ClearAll["Global`*"];
test1[nameOfTestFile_] := Module[{n, res, lst},(*crash*)
   lst = ReadList[nameOfTestFile];
   lst = DeleteCases[lst, Null];
   Do[
    Print["Before calling Integrate"];
    res = TimeConstrained[Integrate[lst[[n, 1]], lst[[n, 2]]], 60*3]
    ,
    {n, 1, Length@lst}  
    ]
   ];

Do[
 test1["Timofeev_Problems.m"];
 Print["Finished"]
 , {myCounter, 1, 1}
 ]

 (*no crash*)

Calling test1 not from inside a loop eliminates the crash

SetDirectory[NotebookDirectory[]];
ClearAll["Global`*"];
test1[nameOfTestFile_] := Module[{n, res, lst},(*crash*)
   lst = ReadList[nameOfTestFile];
   lst = DeleteCases[lst, Null];
   Do[
    Print["Before calling Integrate"];
    res = 
     AbsoluteTiming[TimeConstrained[Integrate[lst[[n, 1]], lst[[n, 2]]], 60*3]]
    ,
    {n, 1, Length@lst}  
    ]
   ];

test1["Timofeev_Problems.m"];
(*no crash, since call is not made from inside a loop !*)

Putting a Block around call to Integrate eliminate crash

SetDirectory[NotebookDirectory[]];
ClearAll["Global`*"];
test1[nameOfTestFile_] := Module[{n, res, lst},(*crash*)
   lst = ReadList[nameOfTestFile];
   lst = DeleteCases[lst, Null];

   Do[
    Print["Before calling Integrate"];
    Block[{},
     res = AbsoluteTiming[TimeConstrained[Integrate[lst[[n, 1]], lst[[n, 2]]], 60*3]]
     ]        
    , {n, 1, Length@lst}
    ]
   ];

Do[
 test1["Timofeev_Problems.m"];
 Print["Finished"],
 {myCounter, 1, 1}
 ]
 (*no crash*)

Putting an If around call to Integrate eliminate crash

SetDirectory[NotebookDirectory[]];
ClearAll["Global`*"];
test1[nameOfTestFile_] := Module[{n, res, lst},(*crash*)
   lst = ReadList[nameOfTestFile];
   lst = DeleteCases[lst, Null];

   Do[
    Print["Before calling Integrate"];
    If[True,
     res = AbsoluteTiming[TimeConstrained[Integrate[lst[[n, 1]], lst[[n, 2]]], 60*3]]
     ]

    , {n, 1, Length@lst}
    ]
   ];

Do[
 test1["Timofeev_Problems.m"];
 Print["Finished"],
 {myCounter, 1, 1}
 ]

 (*no crash*)

Changing the integrand from Sin[x]/(1 + Sin[x]) to Sin[x]/(2 + Sin[x]) eliminates the crash

I think this is the most strange one. Editing Timofeev_Problems.m and changing the integrand from Sin[x]/(1 + Sin[x]) to Sin[x]/(2 + Sin[x]) and keeping everything else the same (i.e. as the same original MWE above), eliminates the crash !

Why would the kernel crash on Sin[x]/(1 + Sin[x]) but not on Sin[x]/(2 + Sin[x])? Notice that Mathematica can integrate both the above, But it crashes only on Sin[x]/(1 + Sin[x]) when it is in the context of the above setup.

Question is: Why Integrate crash above? How to eliminate it? How to find any messages from Kernel what happened, as only a beep is given. Can others reproduce this?

$\endgroup$
  • 3
    $\begingroup$ I can reproduce your problem. No explanation, but here is another thing that eliminates the crash: change Do loop to: Do[{ Print["Before calling Integrate"], res = AbsoluteTiming[TimeConstrained[Integrate[lst[[n, 1]], lst[[n, 2]]], 60*3]] }, {n, 1, Length@lst}] $\endgroup$ – MelaGo Oct 10 at 1:30
  • 1
    $\begingroup$ I reproduced this too. Please report this to Wolfram tech support. $\endgroup$ – Gustavo Delfino Oct 10 at 13:26
  • $\begingroup$ why the downvote? For finding an obscure bug? This is really strange. Makes one not bother mentioning any problems found in the future. $\endgroup$ – Nasser Oct 13 at 0:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.