# Manual CellGrouping option causes crash at cell evaluation

Update: Try to reproduce this behaviour with CellGrouping set to manual. To do that:

• either evaluate SetOptions[$FrontEnd, CellGrouping -> Manual], • or hit CTRL+SHIFT+O to bring up the Option Inspector window, Lookup (among Global preferences) the option CellGrouping and set it to Manual. Please test whether the phenomen is reproducible for you with the changed setting. You can reset cell grouping to its default behaviour by: SetOptions[$FrontEnd, CellGrouping -> Automatic]


Strangest bug ever. Copy the following piece of code to the same notebook two times, below each other, as two identical cells. Be sure to run a fresh kernel.

DynamicModule[{x}, Print[1]; Dynamic@x, Initialization :> Print[2]]


Now evaluate the second cell. Fine, it returns and prints stuff.

And now, without quitting the kernel, evaluate the first cell. It crashes Mathematica. Every time, and only when the first cell is evaluated. If (after a restart) I only evaluate the first cell, Mathematica crashes again.

How come that the outcome of evaluating two identical cells depends on whether the cell is the last one or not?

Furthermore, this one causes a crash on its own:

DynamicModule[{x}, Dynamic@x, Initialization :> Print[2]]


Mathematica 9.0.1.0 Windows 7 (64-bit), no packages, problem persists after full reboot, suggestion bar is turned off.

-
No crash here. works fine. !Mathematica graphics please say which platform and version you are using when reporting possible errors. I am on windows 7, 64 bit, V 9.01 –  Nasser Dec 6 '13 at 14:55
Can't reproduce it in 9.0.1 on Windows 7 x64. The FE code differs substantially between platforms--which one are you on? –  Oleksandr R. Dec 6 '13 at 14:56
Does not crash (MMA 9.0.1 Win7 64). Although I find it a bit strange that 1 gets printed before 2:) –  Ajasja Dec 6 '13 at 15:23
@Ajasja You shouldn't: Initialization code is only evaluated after the return value of the DynamicModule is displayed (see here). –  István Zachar Dec 6 '13 at 15:35
Same behaviour for me, W7 32b MMA 9.0.1 here –  Öskå Dec 6 '13 at 15:36

Tech Support kindly answered and acknowledged the crash:

The crash is now reproducible after setting the option CellGrouping -> Manual. I have forwarded it to the developers for further investigation. You will be informed when a fix is made available.

You can turn off manual CellGrouping with:

SetOptions[\$FrontEnd, CellGrouping -> Automatic]


Also, restarting Mathematica in clean mode resets everything including cell grouping behaviour to defaults and the two cells behave normally. The documentation states:

mathematica.exe -clean: ignore stored caches and rebuild the front end preferences file

(It also seems like from the documentation that this is a Mac-only option, but it also applies to Win.)

-