Giter VIP home page Giter VIP logo

Comments (7)

GgnDpSngh avatar GgnDpSngh commented on July 17, 2024

Hi there,

Thanks for the feedback. I just wanted to check if you are using the latest version? Because the line number 763 in your trace correspond to the "}" statement for me.

Cheers,
Gagandeep Singh

from elina.

mariuscrsn avatar mariuscrsn commented on July 17, 2024

Sorry for the confusion. I added some printf to the file in order to find the bug and I forgot to delete them before running Valgrind. Now I've updated the initial comment with the correct line numbers.

I hope you could find now the bug.

My apologies and thanks again,
Marius.

from elina.

GgnDpSngh avatar GgnDpSngh commented on July 17, 2024

Hi Marius,

Thanks for the update. I am unable to locate the problem, however if you could print the following variables after this line (

size_t nbrows = matF->nbrows;
) then that would help me locate the first error. The variables are:

  1. nbrows
  2. nbvertex
  3. nbline
  4. poly[res]->intdim

Cheers,
Gagandeep Singh

from elina.

mariuscrsn avatar mariuscrsn commented on July 17, 2024

Hi Gagandeep,

First of all, sorry for taking so long to reply. I have been quite busy the past few days.

In my program the function opt_poly_asssub_linexpr_det is invoked twice.
In the next code, I list the values of the variables that I have printed after the line

size_t nbrows = matF->nbrows;

BEGIN opt_poly_asssub_linexpr_det
nbrows: 0
nbvertex: 0
nbline: 1
poly[res]->intdim: 1
BEGIN opt_poly_asssub_linexpr_det
free(): invalid next size (fast)

However, in the second invocation, the if condition

if(flag1 || flag2){
that contain this line is not satisfied. So, I can't print the variables you are asking for.

Finally, the program crash on the line

opt_poly_clear(poly_a[k]);

Next, I list the data of poly_a[k] variable that I've printed just before calling this function:

poly_a[k] data:
intdim: 1
realdim: 0
nbeq: 1
nbline: 0
is_minimized: 0
status: 0
C.nbcolumns: 3
C.nbrows: 1
F.nbcolumns: 3
F.nbrows: 1
satC.nbcolumns: 1
satC.nbrows: 1
calling opt_poly_clear(poly_a[k]); ...
free(): invalid next size (fast)

If I try to print the nbcolumns and nbrows fields of the satF I get a segmentation fault. So, it could be that the problem is in the matrix allocation.

Thank you for all the effort you are putting into solving the problem.

Regards,
Marius.

from elina.

GgnDpSngh avatar GgnDpSngh commented on July 17, 2024

Hi there,

Thanks for the information. I pushed a fix, let me know if the issue is resolved. If not, can you print me the C and F matrix before the crash along with the value of "k" and "num_compa" as well as uncommenting all of he following lines:

//printf("ASSIGN INPUT\n");

Cheers,
Gagandeep Singh

from elina.

mariuscrsn avatar mariuscrsn commented on July 17, 2024

Hi Gagandeep,
it is still not working. It continues to crash in the same line as in previous comments. But don't worry, in the upcoming days, I will check my code to make sure that the crash is not caused by my code.

Anyway, I show you the modifications I have made in the code and the output I get.

I list below the body of this for:

for(k=0; k < num_compa;k++){

for(k=0; k < num_compa;k++){
	printf("poly_a[k] data for k=%d, num_compa=%d:\n", k, num_compa);
	printf("intdim: %d\n", poly_a[k]->intdim);
	printf("realdim: %d\n", poly_a[k]->realdim);
	printf("nbeq: %ld\n", poly_a[k]->nbeq);
	printf("nbline: %ld\n", poly_a[k]->nbline);
	printf("is_minimized: %d\n", poly_a[k]->is_minimized);
	printf("status: %d\n", poly_a[k]->status);
	printf("C->nbcolumns: %d\n", poly_a[k]->C->nbcolumns);
	printf("C->nbrows: %ld\n", poly_a[k]->C->nbrows);
	printf("F->nbcolumns: %d\n", poly_a[k]->F->nbcolumns);
	printf("F->nbrows: %ld\n", poly_a[k]->F->nbrows);
	printf("satC->nbcolumns: %ld\n", poly_a[k]->satC->nbcolumns);
	printf("satC->nbrows: %ld\n", poly_a[k]->satC->nbrows);
	if(!disjoint_map[k]){
		printf("calling opt_poly_clear(poly_a[k])...\n");
		opt_poly_clear(poly_a[k]);
		printf("Call to opt_poly_clear(poly_a[k]) completed\n");
	}
	free(poly_a[k]);
}

In addition, I've uncommented the 8 lines that follow this

//printf("ASSIGN INPUT\n");

The end of the opt_poly_asssub_linexpr_det function looks like this:

    op->poly = poly;
    op->acl = acl;
    free(exc_map);
    printf("ASSIGN OUTPUT\n");
    // print_array_comp_list(acl,op->maxcols);
    elina_lincons0_array_t arr1 = opt_pk_to_lincons_array(man,op);
    elina_lincons0_array_fprint(stdout, &arr1, NULL);
    // elina_lincons0_array_clear(&arr1);
    fflush(stdout);
    printf("Exiting from opt_poly_asssub_linexpr_det");
    return op;

I can't uncomment this two functions ( print_array_comp_list(acl,op->maxcols) and elina_lincons0_array_clear(&arr1)) because it crashes if I do it.

With this code, I get this results:

ASSIGN INPUT
0
empty array of constraints
x0:= 2147483648
ASSIGN OUTPUT
1
array of constraints of size 1
 0: -x0 + 2147483648 = 0
Exiting from opt_poly_asssub_linexpr_det
ASSIGN INPUT
1
array of constraints of size 1
 0: -x0 + 2147483648 = 0
x1:= x0
1
c
3 

poly_a[k] data for k=0, num_compa=1:
intdim: 1
realdim: 0
nbeq: 1
nbline: 0
is_minimized: 0
status: 0
C->nbcolumns: 3
C->nbrows: 1
F->nbcolumns: 3
F->nbrows: 1
satC->nbcolumns: 1
satC->nbrows: 1
calling opt_poly_clear(poly_a[k])...
free(): invalid next size (fast)

In the following days, I will take a look at my code and I will notify you to close the issues or to give you more details about the bug.

Thank you,
Marius.

from elina.

GgnDpSngh avatar GgnDpSngh commented on July 17, 2024

Hi Marius,

Based on your trace, I created a sample program below which produces the same trace but did not observe any crash:

void test_assign(unsigned short int dim, size_t nbcons){
elina_manager_t * man = opt_pk_manager_alloc(false);
opt_pk_array_t * oa1 = opt_pk_top(man, 2,0);
//generate random constraints

elina_dim_t * tdim = (elina_dim_t *)malloc(sizeof(elina_dim_t));
tdim[0] = 0;
elina_linexpr0_t ** expr_array = (elina_linexpr0_t**)malloc(sizeof(elina_linexpr0_t*));
//elina_linexpr0_t * linexpr0 = generate_random_linexpr0(dim);
elina_coeff_t *cst, *coeff;
elina_linexpr0_t * linexpr0 = elina_linexpr0_alloc(ELINA_LINEXPR_SPARSE,0);
cst = &linexpr0->cst;
elina_scalar_set_to_int(cst->val.scalar,2147483648,ELINA_SCALAR_MPQ);

expr_array[0] = linexpr0;
printf("ELINA Input Polyhedron\n");
elina_lincons0_array_t arr1 = opt_pk_to_lincons_array(man,oa1);
elina_lincons0_array_fprint(stdout,&arr1,NULL);
printf("Assignment statement\n");
printf("x%d = ",tdim[0]);
elina_linexpr0_fprint(stdout,linexpr0,NULL);
printf("\n");
fflush(stdout);
elina_lincons0_array_clear(&arr1);
//assign;
opt_pk_assign_linexpr_array(man,true,oa1,tdim, expr_array,1,NULL);
elina_linexpr0_free(linexpr0);

// Print the result
printf("ELINA Output Polyhedron\n");
elina_lincons0_array_t arr = opt_pk_to_lincons_array(man,oa1);
elina_lincons0_array_fprint(stdout,&arr,NULL);
printf("\n");
fflush(stdout);
elina_lincons0_array_clear(&arr);

tdim[0] = 1;
linexpr0 = elina_linexpr0_alloc(ELINA_LINEXPR_SPARSE,1);
cst = &linexpr0->cst;
//int r = rand()%10;
elina_scalar_set_to_int(cst->val.scalar,0,ELINA_SCALAR_MPQ);
elina_linterm_t * linterm = &linexpr0->p.linterm[0];
linterm->dim = 0;
coeff = &linterm->coeff;
elina_scalar_set_to_int(coeff->val.scalar,1,ELINA_SCALAR_MPQ);
expr_array[0] = linexpr0;
//opt_pk_array_t * oa3 = 
opt_pk_assign_linexpr_array(man,true,oa1,tdim, expr_array,1,NULL);

printf("ELINA Output Polyhedron\n");
arr = opt_pk_to_lincons_array(man,oa1);
elina_lincons0_array_fprint(stdout,&arr,NULL);
printf("\n");
fflush(stdout);
elina_lincons0_array_clear(&arr);

free(expr_array);
free(tdim);

opt_pk_free(man,oa1);
elina_manager_free(man);

}

Make sure that you create polyhedra with >=2 variables as I did when calling the top function. Let me know if it helps.

Cheers,
Gagandeep Singh

from elina.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.