Skip to content

Problems when using minkowski_sum by parallel computation (Threads.@threads) #3315

@Xinyi-Yu

Description

@Xinyi-Yu

When I use Threads.@threads to compute minkowski_sum, it seems there are some memory allocation errors.

If the code is as follows, it works by Julia -t 5.

using LazySets
using Polyhedra, CDDLib
const B = [0.125 0;
    0.5 0.0;
    0.0 0.125;
    0.0 0.5
];
const U = Hyperrectangle([0.0, 0.0], [1.0, 1.0]);
Zonotope_BU = convert(Zonotope, B*U);
hpoly_set = HPolytope([LazySets.HalfSpace([0.0, 1.0, 0.0, 0.0], 1.5)]);
Hpoly_union = UnionSetArray([hpoly_set, hpoly_set]);

temp = Vector{Any}(undef, 2);
Threads.@threads for i in 1:2
    temp[i] = minkowski_sum(Hpoly_union[i], Zonotope_BU);
end

But if we change hpoly_set to a more complex form as follows, then it doesn't work. I checked it with linux and LazySets@2.0.0 (Julia 1.7), we will get the following errors. Note that not every time it runs, it will report an error, but it is very common.

I also checked it in windows with LazySets@2.7.4 (Julia 1.7), no matter what hpoly_set is, it will abort directly without printing any information.

hpoly_set = HPolytope([
            LazySets.HalfSpace([0.0, 1.0, 0.0, 0.0], 1.5),
            LazySets.HalfSpace([0.0, 0.0, 1.0, 0.0], 10.0),
            LazySets.HalfSpace([0.0, 0.0, 0.0, 1.0], 1.5),
            LazySets.HalfSpace([-1.0, 0.0, 0.0, 0.0], -0.0),
            LazySets.HalfSpace([0.0, -1.0, 0.0, 0.0], 1.5),
            LazySets.HalfSpace([0.0, 0.0, 0.0, -1.0], 1.5),
            LazySets.HalfSpace([0.0, 0.0, 1.0, 0.5], 10.125),
            LazySets.HalfSpace([0.0, 0.0, 2.0, 2.0], 21.0),
            LazySets.HalfSpace([0.0, 0.0, -2.0, -2.0], -15.0),
            LazySets.HalfSpace([0.0, 0.0, -4.0, -1.0], -27.0),
            LazySets.HalfSpace([-8.0, -4.0, 0.0, 0.0], 1.0),
            LazySets.HalfSpace([2.0, 2.0, 0.0, 0.0], 5.0),
            LazySets.HalfSpace([4.0, 1.0, 0.0, 0.0], 13.0),
            LazySets.HalfSpace([-1.9, -1.9, 0.0, 0.0], 1.0)]);

The error is as follows.

glp_free: memory allocation error
Error detected in file env/alloc.c at line 70

signal (6): Aborted
in expression starting at REPL[9]:1
gsignal at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
abort at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
errfunc at /workspace/srcdir/glpk-5.0/src/env/error.c:53
dma at /workspace/srcdir/glpk-5.0/src/env/alloc.c:70
_glp_lufint_delete at /workspace/srcdir/glpk-5.0/src/bflib/lufint.c:157
_glp_fhvint_delete at /workspace/srcdir/glpk-5.0/src/bflib/fhvint.c:155
_glp_bfd_delete_it at /workspace/srcdir/glpk-5.0/src/draft/bfd.c:526
glp_delete_prob at /workspace/srcdir/glpk-5.0/src/api/prob1.c:1581
glp_delete_prob at /home/dso/.julia/packages/GLPK/lOla6/src/gen/libglpk_api.jl:98 [inlined]
#2 at /home/dso/.julia/packages/GLPK/lOla6/src/MOI_wrapper/MOI_wrapper.jl:189
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1788 [inlined]
run_finalizer at /buildworker/worker/package_linux64/build/src/gc.c:278
jl_gc_run_finalizers_in_list at /buildworker/worker/package_linux64/build/src/gc.c:365
run_finalizers at /buildworker/worker/package_linux64/build/src/gc.c:394
jl_gc_collect at /buildworker/worker/package_linux64/build/src/gc.c:3267
maybe_collect at /buildworker/worker/package_linux64/build/src/gc.c:882 [inlined]
jl_gc_pool_alloc at /buildworker/worker/package_linux64/build/src/gc.c:1209
jl_gc_alloc_ at /buildworker/worker/package_linux64/build/src/julia_internal.h:339 [inlined]
jl_gc_alloc at /buildworker/worker/package_linux64/build/src/gc.c:3290
_new_array_ at /buildworker/worker/package_linux64/build/src/array.c:127
jl_array_copy at /buildworker/worker/package_linux64/build/src/array.c:1200
copy at ./array.jl:369 [inlined]
copy at /home/dso/.julia/packages/MathOptInterface/lHZJh/src/functions.jl:448 [inlined]
canonical at /home/dso/.julia/packages/MathOptInterface/lHZJh/src/Utilities/functions.jl:788
_indices_and_coefficients at /home/dso/.julia/packages/GLPK/lOla6/src/MOI_wrapper/MOI_wrapper.jl:438
add_constraint at /home/dso/.julia/packages/GLPK/lOla6/src/MOI_wrapper/MOI_wrapper.jl:1158
_copy_constraints at /home/dso/.julia/packages/MathOptInterface/lHZJh/src/Utilities/copy.jl:252
_copy_constraints at /home/dso/.julia/packages/MathOptInterface/lHZJh/src/Utilities/copy.jl:264
unknown function (ip: 0x7f8a6141b11d)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
pass_nonvariable_constraints_fallback at /home/dso/.julia/packages/MathOptInterface/lHZJh/src/Utilities/copy.jl:275
pass_nonvariable_constraints at /home/dso/.julia/packages/MathOptInterface/lHZJh/src/Utilities/copy.jl:301 [inlined]
pass_nonvariable_constraints at /home/dso/.julia/packages/MathOptInterface/lHZJh/src/Bridges/bridge_optimizer.jl:435
_pass_constraints at /home/dso/.julia/packages/MathOptInterface/lHZJh/src/Utilities/copy.jl:323
default_copy_to at /home/dso/.julia/packages/MathOptInterface/lHZJh/src/Utilities/copy.jl:498
copy_to at /home/dso/.julia/packages/MathOptInterface/lHZJh/src/Bridges/bridge_optimizer.jl:451 [inlined]
optimize! at /home/dso/.julia/packages/MathOptInterface/lHZJh/src/MathOptInterface.jl:86 [inlined]
optimize! at /home/dso/.julia/packages/MathOptInterface/lHZJh/src/Utilities/cachingoptimizer.jl:316
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
#optimize!#138 at /home/dso/.julia/packages/JuMP/Z1pVn/src/optimizer_interface.jl:185
optimize! at /home/dso/.julia/packages/JuMP/Z1pVn/src/optimizer_interface.jl:163 [inlined]
linprog at /home/dso/.julia/packages/LazySets/R8e5n/src/Initialization/init_JuMP.jl:50
linprog at /home/dso/.julia/packages/LazySets/R8e5n/src/Initialization/init_JuMP.jl:38
#remove_redundant_constraints!#50 at /home/dso/.julia/packages/LazySets/R8e5n/src/Interfaces/AbstractPolyhedron_functions.jl:242
remove_redundant_constraints!##kw at /home/dso/.julia/packages/LazySets/R8e5n/src/Interfaces/AbstractPolyhedron_functions.jl:224 [inlined]
#remove_redundant_constraints!#148 at /home/dso/.julia/packages/LazySets/R8e5n/src/Sets/HPolyhedron.jl:391 [inlined]
remove_redundant_constraints! at /home/dso/.julia/packages/LazySets/R8e5n/src/Sets/HPolyhedron.jl:391
unknown function (ip: 0x7f8a613f5e7d)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
#_minkowski_sum_hrep#447 at /home/dso/.julia/packages/LazySets/R8e5n/src/ConcreteOperations/minkowski_sum.jl:223
_minkowski_sum_hrep##kw at /home/dso/.julia/packages/LazySets/R8e5n/src/ConcreteOperations/minkowski_sum.jl:202
unknown function (ip: 0x7f8a613eb171)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
_minkowski_sum_hrep_preprocess at /home/dso/.julia/packages/LazySets/R8e5n/src/ConcreteOperations/minkowski_sum.jl:188
#minkowski_sum#445 at /home/dso/.julia/packages/LazySets/R8e5n/src/ConcreteOperations/minkowski_sum.jl:170
minkowski_sum at /home/dso/.julia/packages/LazySets/R8e5n/src/ConcreteOperations/minkowski_sum.jl:161
unknown function (ip: 0x7f8a6139ee88)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
macro expansion at ./REPL[9]:2 [inlined]
#129#threadsfor_fun at ./threadingconstructs.jl:85
#129#threadsfor_fun at ./threadingconstructs.jl:52
unknown function (ip: 0x7f8a6142293f)
_jl_invoke at /buildworker/worker/package_linux64/build/src/gf.c:2247 [inlined]
jl_apply_generic at /buildworker/worker/package_linux64/build/src/gf.c:2429
jl_apply at /buildworker/worker/package_linux64/build/src/julia.h:1788 [inlined]
start_task at /buildworker/worker/package_linux64/build/src/task.c:877
Allocations: 101808403 (Pool: 101777881; Big: 30522); GC: 60
Aborted (core dumped)

Metadata

Metadata

Assignees

No one assigned

    Labels

    external 📤Related to external packages

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions