Instruction how to crash SU Pro v. 23.0.419 64-bit

Start placing any component from Components tray, but do not finish it by clicking on the scene. While in this state open console and enter there
d = Sketchup.active_model.definitions.to_a.last; 20.times{|i| d.set_attribute(“qwe#{i}”, ‘asd’, ‘zxc’)}
SU crashes at this point.
If you use attribute dictionary which already existed there, like ‘dynamic_attributes’, then it will not crash.

Not the case for earlier versions of SU

Yes, crashes are bad, but this scenario is not something that any coder would do.

The likely reason for the crash is that the definition is removed if the instance placing is abandoned.

The lesson here is that you should try to attach attribute dictionaries after SketchUp has reported the definition is added in a DefinitionsObserver. Sometimes doing changes in observer callbacks must be delayed using a timer, … or only after one of it’s instances is placed in the model with DefinitionObserver#onComponentInstanceAdded.

Extensions must not do this … ie, making randomly named dictionaries. The model data space is shared space.

This means that all dictionaries created by extensions must be qualified with the coder’s namespace module name and the extension name to which it belongs.

As an example, "dynamic_attributes" is a non-qualified dictionary name. It should have been qualified as newer native dictionaries are with a "SU_" prefix, but it was done many years ago in the API’s infancy before best practices were known.

You can post a bug report in the official API bug tracker at GitHub:

Point was to show that it crashes if set_attribute() creates new dictionary. In fact most of the times it will crash with only

Sketchup.active_model.definitions.to_a.last.set_attribute('non_existing_yet_dictionary_name', 'anything', 'anything')

sry if “qwe#{i}” brought confusion here, but it was to force new dictionary creation on each iteration

Better tell me if you were able to reproduce crash following my instruction, ty.

Yes, it took 4 trys to get the crash. Crash #201735

I think this occurs when pulling in new components only.
Have you gotten this to crash when dragging components whose definition is already in the model ?

Seems you are right

Go ahead and post a bug report in the official API bug tracker at GitHub: