Wrong user counter on curves with shared material #61660

Closed
opened 2019-02-18 10:57:31 +01:00 by Sergey Sharybin · 7 comments

System Information

Operating system: Linux, 64bit, Debian Buster
Graphics card: GTX 1080

Blender Version
Broken: 1c3a098cc8
Worked: blender2.7

Short description of error

Cycles causes wrong user counter on a curves which are sharing same material.
Probably harmless, but rather annoying and causes confusion.

Exact steps for others to reproduce the error

Open attached file, hit F12.

The issue is caused by the way how Cycles works with the objects: it gets evaluated object and requests Mesh created from it. This is done using BKE_mesh_new_from_object(). This function places created mesh to bmain, which makes it expected to be properly user-counted.

However, due to the nature of the input datablock this doesn't quite work: input datablocks are outside of the database and are not user-counted. They can not be reliably user-counted since they are coming from a dependency graph, which is a sub-set of bmain (which makes it wrong to simply copy user counts), and we can't easily deduct number of users from relations either (there might be extra nodes between ID which uses something and that used ID). So, since this can't be done reliably, dependency graph doesn't user-count anything.

Proposed solution is to not do user counting on ID which are outside of bmain as well: P914: User counter fix

diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c
index 92b3e581fa5..ac6f03e0bfb 100644
--- a/source/blender/blenkernel/intern/library_remap.c
+++ b/source/blender/blenkernel/intern/library_remap.c
@@ -245,10 +245,20 @@ static int foreach_libblock_remap_callback(void *user_data, ID *id_self, ID **id
 				                     ID_RECALC_COPY_ON_WRITE | ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY);
 			}
 			if (cb_flag & IDWALK_CB_USER) {
-				id_us_min(old_id);
+				/* NOTE: We don't user-count IDs which are not in the main database.
+				 * This is because in certain conditions we can have datablocks in
+				 * the main which are referencing datablocks outside of it.
+				 * For example, BKE_mesh_new_from_object() called on an evaluated
+				 * object will cause such situation. */
+				if ((old_id->tag & LIB_TAG_NO_MAIN) == 0) {
+					id_us_min(old_id);
+				}
 				/* We do not want to handle LIB_TAG_INDIRECT/LIB_TAG_EXTERN here. */
-				if (new_id)
-					new_id->us++;
+				if (new_id) {
+					if ((new_id->tag & LIB_TAG_NO_MAIN) == 0) {
+						new_id->us++;
+					}
+				}
 			}
 			else if (cb_flag & IDWALK_CB_USER_ONE) {
 				id_us_ensure_real(new_id);

shared_curve_material.blend

**System Information** Operating system: Linux, 64bit, Debian Buster Graphics card: GTX 1080 **Blender Version** Broken: 1c3a098cc8 Worked: blender2.7 **Short description of error** Cycles causes wrong user counter on a curves which are sharing same material. Probably harmless, but rather annoying and causes confusion. **Exact steps for others to reproduce the error** Open attached file, hit F12. The issue is caused by the way how Cycles works with the objects: it gets evaluated object and requests Mesh created from it. This is done using `BKE_mesh_new_from_object()`. This function places created mesh to `bmain`, which makes it expected to be properly user-counted. However, due to the nature of the input datablock this doesn't quite work: input datablocks are outside of the database and are not user-counted. They can not be reliably user-counted since they are coming from a dependency graph, which is a sub-set of bmain (which makes it wrong to simply copy user counts), and we can't easily deduct number of users from relations either (there might be extra nodes between ID which uses something and that used ID). So, since this can't be done reliably, dependency graph doesn't user-count anything. Proposed solution is to not do user counting on ID which are outside of `bmain` as well: [P914: User counter fix](https://archive.blender.org/developer/P914.txt) ``` diff --git a/source/blender/blenkernel/intern/library_remap.c b/source/blender/blenkernel/intern/library_remap.c index 92b3e581fa5..ac6f03e0bfb 100644 --- a/source/blender/blenkernel/intern/library_remap.c +++ b/source/blender/blenkernel/intern/library_remap.c @@ -245,10 +245,20 @@ static int foreach_libblock_remap_callback(void *user_data, ID *id_self, ID **id ID_RECALC_COPY_ON_WRITE | ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY); } if (cb_flag & IDWALK_CB_USER) { - id_us_min(old_id); + /* NOTE: We don't user-count IDs which are not in the main database. + * This is because in certain conditions we can have datablocks in + * the main which are referencing datablocks outside of it. + * For example, BKE_mesh_new_from_object() called on an evaluated + * object will cause such situation. */ + if ((old_id->tag & LIB_TAG_NO_MAIN) == 0) { + id_us_min(old_id); + } /* We do not want to handle LIB_TAG_INDIRECT/LIB_TAG_EXTERN here. */ - if (new_id) - new_id->us++; + if (new_id) { + if ((new_id->tag & LIB_TAG_NO_MAIN) == 0) { + new_id->us++; + } + } } else if (cb_flag & IDWALK_CB_USER_ONE) { id_us_ensure_real(new_id); ``` [shared_curve_material.blend](https://archive.blender.org/developer/F6648486/shared_curve_material.blend)
Author
Owner

Added subscriber: @Sergey

Added subscriber: @Sergey
Sergey Sharybin self-assigned this 2019-02-18 10:58:33 +01:00
Author
Owner

Added subscribers: @brecht, @mont29

Added subscribers: @brecht, @mont29
Author
Owner

Side note: this file also shows a leak of bounding box: P915: Boundbox leak :(

=================================================================
==8812==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 1406312 byte(s) in 747 object(s) allocated from:
    #0 0x7f154e0fbef0 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe8ef0)
    #1 0x5585da2f806b in _PyObject_Malloc Objects/obmalloc.c:1560

Direct leak of 2232 byte(s) in 4 object(s) allocated from:
    #0 0x7f154e0fbef0 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe8ef0)
    #1 0x5585da2f8153 in _PyObject_Malloc Objects/obmalloc.c:1560
    #2 0x5585da2f8153 in pymalloc_realloc Objects/obmalloc.c:1882
    #3 0x5585da2f8153 in _PyObject_Realloc Objects/obmalloc.c:1901

Direct leak of 534 byte(s) in 1 object(s) allocated from:
    #0 0x7f154e0fc2e0 in realloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe92e0)
    #1 0x5585da2f810e in _PyObject_Realloc Objects/obmalloc.c:1905

Direct leak of 512 byte(s) in 1 object(s) allocated from:
    #0 0x7f154e0fc0d8 in __interceptor_calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe90d8)
    #1 0x7f1548bcbfe1  (<unknown module>)

Direct leak of 224 byte(s) in 2 object(s) allocated from:
    #0 0x7f154e0fbef0 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe8ef0)
    #1 0x5585cfe28eb8 in MEM_lockfree_mallocN /home/sergey/Developer/blender/blender/intern/guardedalloc/intern/mallocn_lockfree_impl.c:310
    #2 0x5585cfe28868 in MEM_lockfree_dupallocN /home/sergey/Developer/blender/blender/intern/guardedalloc/intern/mallocn_lockfree_impl.c:178
    #3 0x5585ced30cfa in BKE_object_copy_data /home/sergey/Developer/blender/blender/source/blender/blenkernel/intern/object.c:1346
    #4 0x5585cebb98c9 in BKE_id_copy_ex /home/sergey/Developer/blender/blender/source/blender/blenkernel/intern/library.c:569
    #5 0x5585cf8822b2 in id_copy_inplace_no_main /home/sergey/Developer/blender/blender/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc:291
    #6 0x5585cf88408f in DEG::deg_expand_copy_on_write_datablock(DEG::Depsgraph const*, DEG::IDNode const*, DEG::DepsgraphNodeBuilder*, bool) /home/sergey/Developer/blender/blender/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc:737
    #7 0x5585cf8854ec in DEG::deg_update_copy_on_write_datablock(DEG::Depsgraph const*, DEG::IDNode const*) /home/sergey/Developer/blender/blender/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc:942
    #8 0x5585cf885dfb in DEG::deg_evaluate_copy_on_write(Depsgraph*, DEG::IDNode const*) /home/sergey/Developer/blender/blender/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc:1092
    #9 0x5585cf851d0f in void std::__invoke_impl<void, void (*&)(Depsgraph*, DEG::IDNode const*), Depsgraph*, DEG::IDNode*&>(std::__invoke_other, void (*&)(Depsgraph*, DEG::IDNode const*), Depsgraph*&&, DEG::IDNode*&) /usr/include/c++/8/bits/invoke.h:60
    #10 0x5585cf84f784 in std::__invoke_result<void (*&)(Depsgraph*, DEG::IDNode const*), Depsgraph*, DEG::IDNode*&>::type std::__invoke<void (*&)(Depsgraph*, DEG::IDNode const*), Depsgraph*, DEG::IDNode*&>(void (*&)(Depsgraph*, DEG::IDNode const*), Depsgraph*&&, DEG::IDNode*&) /usr/include/c++/8/bits/invoke.h:95
    #11 0x5585cf84caae in void std::_Bind<void (*(std::_Placeholder<1>, DEG::IDNode*))(Depsgraph*, DEG::IDNode const*)>::__call<void, Depsgraph*&&, 0ul, 1ul>(std::tuple<Depsgraph*&&>&&, std::_Index_tuple<0ul, 1ul>) /usr/include/c++/8/functional:400
    #12 0x5585cf847fb5 in void std::_Bind<void (*(std::_Placeholder<1>, DEG::IDNode*))(Depsgraph*, DEG::IDNode const*)>::operator()<Depsgraph*, void>(Depsgraph*&&) /usr/include/c++/8/functional:484
    #13 0x5585cf841d23 in std::_Function_handler<void (Depsgraph*), std::_Bind<void (*(std::_Placeholder<1>, DEG::IDNode*))(Depsgraph*, DEG::IDNode const*)> >::_M_invoke(std::_Any_data const&, Depsgraph*&&) /usr/include/c++/8/bits/std_function.h:297
    #14 0x5585cf880631 in std::function<void (Depsgraph*)>::operator()(Depsgraph*) const /usr/include/c++/8/bits/std_function.h:687
    #15 0x5585cf87e8e7 in deg_task_run_func /home/sergey/Developer/blender/blender/source/blender/depsgraph/intern/eval/deg_eval.cc:88
    #16 0x5585cf7e69f4 in handle_local_queue /home/sergey/Developer/blender/blender/source/blender/blenlib/intern/task.c:417
    #17 0x5585cf7e69f4 in BLI_task_pool_work_and_wait /home/sergey/Developer/blender/blender/source/blender/blenlib/intern/task.c:904
    #18 0x5585cf7e6d1e in BLI_task_pool_work_wait_and_reset /home/sergey/Developer/blender/blender/source/blender/blenlib/intern/task.c:925
    #19 0x5585cf88033f in DEG::deg_evaluate_on_refresh(DEG::Depsgraph*) /home/sergey/Developer/blender/blender/source/blender/depsgraph/intern/eval/deg_eval.cc:317
    #20 0x5585cf81bd4c in DEG_evaluate_on_framechange /home/sergey/Developer/blender/blender/source/blender/depsgraph/intern/depsgraph_eval.cc:83
    #21 0x5585cee614e2 in BKE_scene_graph_update_for_newframe /home/sergey/Developer/blender/blender/source/blender/blenkernel/intern/scene.c:1542
    #22 0x5585cd696ce3 in engine_depsgraph_init /home/sergey/Developer/blender/blender/source/blender/render/intern/source/external_engine.c:496
    #23 0x5585cd698abc in RE_engine_render /home/sergey/Developer/blender/blender/source/blender/render/intern/source/external_engine.c:725
    #24 0x5585cd6ad6d7 in do_render_3d /home/sergey/Developer/blender/blender/source/blender/render/intern/source/pipeline.c:1080
    #25 0x5585cd6ae1b3 in do_render /home/sergey/Developer/blender/blender/source/blender/render/intern/source/pipeline.c:1156
    #26 0x5585cd6af60d in do_render_composite /home/sergey/Developer/blender/blender/source/blender/render/intern/source/pipeline.c:1362
    #27 0x5585cd6b1882 in do_render_all_options /home/sergey/Developer/blender/blender/source/blender/render/intern/source/pipeline.c:1629
    #28 0x5585cd6b839b in RE_BlenderAnim /home/sergey/Developer/blender/blender/source/blender/render/intern/source/pipeline.c:2481
    #29 0x5585cc4c05d6 in arg_handle_render_frame /home/sergey/Developer/blender/blender/source/creator/creator_args.c:1457
    #30 0x5585cf6977f4 in BLI_argsParse /home/sergey/Developer/blender/blender/source/blender/blenlib/intern/BLI_args.c:274

Direct leak of 96 byte(s) in 3 object(s) allocated from:
    #0 0x7f154e0fbef0 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe8ef0)
    #1 0x5585da39bab4 in PyThread_allocate_lock Python/thread_pthread.h:257

Direct leak of 8 byte(s) in 1 object(s) allocated from:
    #0 0x7f154e0fd920 in operator new(unsigned long) (/lib/x86_64-linux-gnu/libasan.so.5+0xea920)
    #1 0x5585dae6be41 in IlmThread_2_3::ThreadPool::setNumThreads(int) (/home/sergey/Developer/blender/build/cmake-debug/bin/blender+0x12605e41)
    #2 0x5585dadc3198 in Imf_2_3::setGlobalThreadCount(int) (/home/sergey/Developer/blender/build/cmake-debug/bin/blender+0x1255d198)
    #3 0x5585cf93f830 in imb_exitopenexr /home/sergey/Developer/blender/blender/source/blender/imbuf/intern/openexr/openexr_api.cpp:1921
    #4 0x5585cf611808 in imb_filetypes_exit /home/sergey/Developer/blender/blender/source/blender/imbuf/intern/filetype.c:102
    #5 0x5585cf6300b0 in IMB_exit /home/sergey/Developer/blender/blender/source/blender/imbuf/intern/module.c:43
    #6 0x5585ce95e4fe in BKE_blender_free /home/sergey/Developer/blender/blender/source/blender/blenkernel/intern/blender.c:89
    #7 0x5585cc505dba in WM_exit_ext /home/sergey/Developer/blender/blender/source/blender/windowmanager/intern/wm_init_exit.c:509
    #8 0x5585cc5060b3 in WM_exit /home/sergey/Developer/blender/blender/source/blender/windowmanager/intern/wm_init_exit.c:604
    #9 0x5585cc4bbb5f in main /home/sergey/Developer/blender/blender/source/creator/creator.c:497
    #10 0x7f154d1e509a in __libc_start_main ../csu/libc-start.c:308

Indirect leak of 1117261 byte(s) in 1202 object(s) allocated from:
    #0 0x7f154e0fbef0 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe8ef0)
    #1 0x5585da2f806b in _PyObject_Malloc Objects/obmalloc.c:1560

Indirect leak of 544 byte(s) in 1 object(s) allocated from:
    #0 0x7f154e0fbef0 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe8ef0)
    #1 0x5585da2f8153 in _PyObject_Malloc Objects/obmalloc.c:1560
    #2 0x5585da2f8153 in pymalloc_realloc Objects/obmalloc.c:1882
    #3 0x5585da2f8153 in _PyObject_Realloc Objects/obmalloc.c:1901

Indirect leak of 64 byte(s) in 1 object(s) allocated from:
    #0 0x7f154e0fc0d8 in __interceptor_calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe90d8)
    #1 0x7f1548bca222  (<unknown module>)

Indirect leak of 16 byte(s) in 1 object(s) allocated from:
    #0 0x7f154e0fbef0 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe8ef0)
    #1 0x7f1548bca205  (<unknown module>)

SUMMARY: AddressSanitizer: 2527803 byte(s) leaked in 1964 allocation(s).

Like, an icing on the cake :)

Side note: this file also shows a leak of bounding box: [P915: Boundbox leak :(](https://archive.blender.org/developer/P915.txt) ``` ================================================================= ==8812==ERROR: LeakSanitizer: detected memory leaks Direct leak of 1406312 byte(s) in 747 object(s) allocated from: #0 0x7f154e0fbef0 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe8ef0) #1 0x5585da2f806b in _PyObject_Malloc Objects/obmalloc.c:1560 Direct leak of 2232 byte(s) in 4 object(s) allocated from: #0 0x7f154e0fbef0 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe8ef0) #1 0x5585da2f8153 in _PyObject_Malloc Objects/obmalloc.c:1560 #2 0x5585da2f8153 in pymalloc_realloc Objects/obmalloc.c:1882 #3 0x5585da2f8153 in _PyObject_Realloc Objects/obmalloc.c:1901 Direct leak of 534 byte(s) in 1 object(s) allocated from: #0 0x7f154e0fc2e0 in realloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe92e0) #1 0x5585da2f810e in _PyObject_Realloc Objects/obmalloc.c:1905 Direct leak of 512 byte(s) in 1 object(s) allocated from: #0 0x7f154e0fc0d8 in __interceptor_calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe90d8) #1 0x7f1548bcbfe1 (<unknown module>) Direct leak of 224 byte(s) in 2 object(s) allocated from: #0 0x7f154e0fbef0 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe8ef0) #1 0x5585cfe28eb8 in MEM_lockfree_mallocN /home/sergey/Developer/blender/blender/intern/guardedalloc/intern/mallocn_lockfree_impl.c:310 #2 0x5585cfe28868 in MEM_lockfree_dupallocN /home/sergey/Developer/blender/blender/intern/guardedalloc/intern/mallocn_lockfree_impl.c:178 #3 0x5585ced30cfa in BKE_object_copy_data /home/sergey/Developer/blender/blender/source/blender/blenkernel/intern/object.c:1346 #4 0x5585cebb98c9 in BKE_id_copy_ex /home/sergey/Developer/blender/blender/source/blender/blenkernel/intern/library.c:569 #5 0x5585cf8822b2 in id_copy_inplace_no_main /home/sergey/Developer/blender/blender/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc:291 #6 0x5585cf88408f in DEG::deg_expand_copy_on_write_datablock(DEG::Depsgraph const*, DEG::IDNode const*, DEG::DepsgraphNodeBuilder*, bool) /home/sergey/Developer/blender/blender/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc:737 #7 0x5585cf8854ec in DEG::deg_update_copy_on_write_datablock(DEG::Depsgraph const*, DEG::IDNode const*) /home/sergey/Developer/blender/blender/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc:942 #8 0x5585cf885dfb in DEG::deg_evaluate_copy_on_write(Depsgraph*, DEG::IDNode const*) /home/sergey/Developer/blender/blender/source/blender/depsgraph/intern/eval/deg_eval_copy_on_write.cc:1092 #9 0x5585cf851d0f in void std::__invoke_impl<void, void (*&)(Depsgraph*, DEG::IDNode const*), Depsgraph*, DEG::IDNode*&>(std::__invoke_other, void (*&)(Depsgraph*, DEG::IDNode const*), Depsgraph*&&, DEG::IDNode*&) /usr/include/c++/8/bits/invoke.h:60 #10 0x5585cf84f784 in std::__invoke_result<void (*&)(Depsgraph*, DEG::IDNode const*), Depsgraph*, DEG::IDNode*&>::type std::__invoke<void (*&)(Depsgraph*, DEG::IDNode const*), Depsgraph*, DEG::IDNode*&>(void (*&)(Depsgraph*, DEG::IDNode const*), Depsgraph*&&, DEG::IDNode*&) /usr/include/c++/8/bits/invoke.h:95 #11 0x5585cf84caae in void std::_Bind<void (*(std::_Placeholder<1>, DEG::IDNode*))(Depsgraph*, DEG::IDNode const*)>::__call<void, Depsgraph*&&, 0ul, 1ul>(std::tuple<Depsgraph*&&>&&, std::_Index_tuple<0ul, 1ul>) /usr/include/c++/8/functional:400 #12 0x5585cf847fb5 in void std::_Bind<void (*(std::_Placeholder<1>, DEG::IDNode*))(Depsgraph*, DEG::IDNode const*)>::operator()<Depsgraph*, void>(Depsgraph*&&) /usr/include/c++/8/functional:484 #13 0x5585cf841d23 in std::_Function_handler<void (Depsgraph*), std::_Bind<void (*(std::_Placeholder<1>, DEG::IDNode*))(Depsgraph*, DEG::IDNode const*)> >::_M_invoke(std::_Any_data const&, Depsgraph*&&) /usr/include/c++/8/bits/std_function.h:297 #14 0x5585cf880631 in std::function<void (Depsgraph*)>::operator()(Depsgraph*) const /usr/include/c++/8/bits/std_function.h:687 #15 0x5585cf87e8e7 in deg_task_run_func /home/sergey/Developer/blender/blender/source/blender/depsgraph/intern/eval/deg_eval.cc:88 #16 0x5585cf7e69f4 in handle_local_queue /home/sergey/Developer/blender/blender/source/blender/blenlib/intern/task.c:417 #17 0x5585cf7e69f4 in BLI_task_pool_work_and_wait /home/sergey/Developer/blender/blender/source/blender/blenlib/intern/task.c:904 #18 0x5585cf7e6d1e in BLI_task_pool_work_wait_and_reset /home/sergey/Developer/blender/blender/source/blender/blenlib/intern/task.c:925 #19 0x5585cf88033f in DEG::deg_evaluate_on_refresh(DEG::Depsgraph*) /home/sergey/Developer/blender/blender/source/blender/depsgraph/intern/eval/deg_eval.cc:317 #20 0x5585cf81bd4c in DEG_evaluate_on_framechange /home/sergey/Developer/blender/blender/source/blender/depsgraph/intern/depsgraph_eval.cc:83 #21 0x5585cee614e2 in BKE_scene_graph_update_for_newframe /home/sergey/Developer/blender/blender/source/blender/blenkernel/intern/scene.c:1542 #22 0x5585cd696ce3 in engine_depsgraph_init /home/sergey/Developer/blender/blender/source/blender/render/intern/source/external_engine.c:496 #23 0x5585cd698abc in RE_engine_render /home/sergey/Developer/blender/blender/source/blender/render/intern/source/external_engine.c:725 #24 0x5585cd6ad6d7 in do_render_3d /home/sergey/Developer/blender/blender/source/blender/render/intern/source/pipeline.c:1080 #25 0x5585cd6ae1b3 in do_render /home/sergey/Developer/blender/blender/source/blender/render/intern/source/pipeline.c:1156 #26 0x5585cd6af60d in do_render_composite /home/sergey/Developer/blender/blender/source/blender/render/intern/source/pipeline.c:1362 #27 0x5585cd6b1882 in do_render_all_options /home/sergey/Developer/blender/blender/source/blender/render/intern/source/pipeline.c:1629 #28 0x5585cd6b839b in RE_BlenderAnim /home/sergey/Developer/blender/blender/source/blender/render/intern/source/pipeline.c:2481 #29 0x5585cc4c05d6 in arg_handle_render_frame /home/sergey/Developer/blender/blender/source/creator/creator_args.c:1457 #30 0x5585cf6977f4 in BLI_argsParse /home/sergey/Developer/blender/blender/source/blender/blenlib/intern/BLI_args.c:274 Direct leak of 96 byte(s) in 3 object(s) allocated from: #0 0x7f154e0fbef0 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe8ef0) #1 0x5585da39bab4 in PyThread_allocate_lock Python/thread_pthread.h:257 Direct leak of 8 byte(s) in 1 object(s) allocated from: #0 0x7f154e0fd920 in operator new(unsigned long) (/lib/x86_64-linux-gnu/libasan.so.5+0xea920) #1 0x5585dae6be41 in IlmThread_2_3::ThreadPool::setNumThreads(int) (/home/sergey/Developer/blender/build/cmake-debug/bin/blender+0x12605e41) #2 0x5585dadc3198 in Imf_2_3::setGlobalThreadCount(int) (/home/sergey/Developer/blender/build/cmake-debug/bin/blender+0x1255d198) #3 0x5585cf93f830 in imb_exitopenexr /home/sergey/Developer/blender/blender/source/blender/imbuf/intern/openexr/openexr_api.cpp:1921 #4 0x5585cf611808 in imb_filetypes_exit /home/sergey/Developer/blender/blender/source/blender/imbuf/intern/filetype.c:102 #5 0x5585cf6300b0 in IMB_exit /home/sergey/Developer/blender/blender/source/blender/imbuf/intern/module.c:43 #6 0x5585ce95e4fe in BKE_blender_free /home/sergey/Developer/blender/blender/source/blender/blenkernel/intern/blender.c:89 #7 0x5585cc505dba in WM_exit_ext /home/sergey/Developer/blender/blender/source/blender/windowmanager/intern/wm_init_exit.c:509 #8 0x5585cc5060b3 in WM_exit /home/sergey/Developer/blender/blender/source/blender/windowmanager/intern/wm_init_exit.c:604 #9 0x5585cc4bbb5f in main /home/sergey/Developer/blender/blender/source/creator/creator.c:497 #10 0x7f154d1e509a in __libc_start_main ../csu/libc-start.c:308 Indirect leak of 1117261 byte(s) in 1202 object(s) allocated from: #0 0x7f154e0fbef0 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe8ef0) #1 0x5585da2f806b in _PyObject_Malloc Objects/obmalloc.c:1560 Indirect leak of 544 byte(s) in 1 object(s) allocated from: #0 0x7f154e0fbef0 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe8ef0) #1 0x5585da2f8153 in _PyObject_Malloc Objects/obmalloc.c:1560 #2 0x5585da2f8153 in pymalloc_realloc Objects/obmalloc.c:1882 #3 0x5585da2f8153 in _PyObject_Realloc Objects/obmalloc.c:1901 Indirect leak of 64 byte(s) in 1 object(s) allocated from: #0 0x7f154e0fc0d8 in __interceptor_calloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe90d8) #1 0x7f1548bca222 (<unknown module>) Indirect leak of 16 byte(s) in 1 object(s) allocated from: #0 0x7f154e0fbef0 in __interceptor_malloc (/lib/x86_64-linux-gnu/libasan.so.5+0xe8ef0) #1 0x7f1548bca205 (<unknown module>) SUMMARY: AddressSanitizer: 2527803 byte(s) leaked in 1964 allocation(s). ``` Like, an icing on the cake :)

Re usercount of IDs outside of a Main, main library.c code already expects outside-of-main IDs to not do any refcounting (with things like BLI_assert((flag & LIB_ID_CREATE_NO_MAIN) == 0 || (flag & LIB_ID_CREATE_NO_USER_REFCOUNT) != 0); e.g.).

So I think that this handling should actually be done by library_query code itself (i.e. removing IDWALK_CB_USER / IDWALK_CB_USER_ONE from callback flags when processed ID is tagged with LIB_TAG_NO_MAIN?

Re usercount of IDs outside of a Main, main library.c code already expects outside-of-main IDs to not do any refcounting (with things like `BLI_assert((flag & LIB_ID_CREATE_NO_MAIN) == 0 || (flag & LIB_ID_CREATE_NO_USER_REFCOUNT) != 0);` e.g.). So I think that this handling should actually be done by library_query code itself (i.e. removing `IDWALK_CB_USER` / `IDWALK_CB_USER_ONE` from callback flags when processed ID is tagged with `LIB_TAG_NO_MAIN`?
Author
Owner

@mont29, i am not really sure what exact you mean by should actually be done by library_query code itself.
Thing is, you can not do it in one single place: the situation is such that datablock from bmain is referencing datablocks which are outside of it.

It might also be easier to talk patches language ;)

@mont29, i am not really sure what exact you mean by `should actually be done by library_query code itself`. Thing is, you can not do it in one single place: the situation is such that datablock from bmain is referencing datablocks which are outside of it. It might also be easier to talk patches language ;)

This issue was referenced by 5d58b7f073

This issue was referenced by 5d58b7f073987543d8d952587a8ffd1268ca443e

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#61660
No description provided.