System Information
Operating system: Linux-5.16.0-4-amd64-x86_64-with-glibc2.33 64 Bits
Graphics card: Quadro RTX 6000/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 510.54
Blender Version
Broken: version: 3.2.0 Alpha, branch: Unknown, commit date: Unknown Unknown, hash: rBUnknown
Worked: Prior to D11597 rBc946fdb2e5f
Short description of error
Rendering on playing back lib/tests/render/motion_blur/multi_step_motion_blur.blend results in memory leak.
Exact steps for others to reproduce the error
Easiest to see if LSAN is enabled, but guarded allocator also catches the issue.
Way 1: Open the file, hit F12, observe memory leak printed on exit.
Way 2: Open the file, hit playback, exit
There are two things which on a glance seems to be wrong in the new implementation (since the mentioned patch) in the BKE_displist_make_curveTypes.
The ob->data at the moment of the function is called is not "localized" to the object: if multiple objects are sharing the same curve multiple copy-on-write objects will share the same copy-on-write curve. This means that writing to cow_curve.curve_eval is "illegal". The general rule: do not write to object-data level when evaluating object. This general rule is violated without either explanation or realization that it is something bad.
The freeing of Curve::curve_eval is only happening in the curve_free_data, which means evaluating same depsgraph at different times will not free this data: cow_curve.curve_eval = nullptr;.
P.S. The comment in the Curve::CurveEval states Owned by the object's #geometry_set_eval. That's the giveaway: something owned by object level can not be stored in the object-data level.
