id	summary	reporter	owner	description	type	status	priority	milestone	component	resolution	keywords	cc
1092	Crash saving games in debug-mode: Compartment mismatch	Yves	Yves	"When saving a game in debug-mode it crashes.
Apparently the reason is that SavedGames::Save tries calling ""SetProperty"" with a value returned by the GUI's scriptinterface using it's own instance of scriptinterface (simulation.GetScriptInterface()).


{{{
simulation.GetScriptInterface().SetProperty(metadata.get(), ""gui"", gui->GetSavedGameData());
}}}

Each scriptinterface uses its own Spidermonkey runtime with an own compartment.  the Value returned by gui->GetSavedGameData() ""contains"" another compartment than the one contained in the scriptinterface object of simulation. Spidermonkey checks if they match and raises an exception in debug mode because they don't.

In release mode everything seems to work fine, but there are probably some hidden problems there too because the compartments don't match either. 

According to the Spidermonkey documentation objects of one compartment can't be used in another one by default, but there seem to be ways to interchange objects between compartments.
I've started looking into spidermonkey a few hours ago, so I don't yet fully understand it. I'll need a bit more time before I know more details and what an appropriate solution would be.
"	defect	closed	Should Have	Alpha 9	Core engine	fixed		Yves
