Allocation failed: std::bad_alloc with method using isl library methods

68 Views Asked by At

The following method is causing bad memory allocation exceptions, I can't seem to find where this is exactly happening, for context the method is using the isl library to construct a map containing a set of iterators names with their number of constraints:


    std::unordered_map<std::string, int> utility::get_constraints_map(isl_set *set)
    {
    isl_basic_set_list *bset_list = isl_set_get_basic_set_list(set);
    std::unordered_map<std::string, int> constraints_map{};
    
    int n_basic_set = isl_set_n_basic_set(set);
    for (int i = 0; i < n_basic_set; i++)
    {
        isl_basic_set *bset = isl_basic_set_list_get_basic_set(bset_list, i);
        isl_constraint_list *cst_list = isl_basic_set_get_constraint_list(bset);
        for (int j = 0; j < isl_constraint_list_n_constraint(cst_list); j++)
        {
            isl_constraint *cst = isl_constraint_list_get_constraint(cst_list, j);
    
            for (int k = 0; k < isl_set_dim(set, isl_dim_out); k++)
            {
                std::string dim_name = isl_set_get_dim_name(set, isl_dim_out, k);
            
                if (isl_constraint_involves_dims(cst, isl_dim_set, k, 1))
                {
                    if (constraints_map.find(dim_name) != constraints_map.end())
                    {
                        constraints_map.at(dim_name) = constraints_map[dim_name] + 1;
                    }
                    else
                    {
                        constraints_map.insert({dim_name, 0});
                    }
                    break;
                }
            }
        }
    
    }
        return constraints_map;

    }

I tried to free each object (stil same problem) using the dedicated isl methods:

    isl_constraint_free
    isl_basic_set_free
    isl_
0

There are 0 best solutions below