Segmentation fault in hMetis interface function

Hi,

We are trying to use hMetis to partition the VLSI circuit. The standalone program works fine. However, the interface function ran into segmentation fault even with a very simple case as below,

nvtxs = 3, nhedges = 3, nparts = 3, ubfactor = 20
eptr = { 0 2 4 6 }
eind = { 2 3 1 2 1 3 }
part = { -1 -1 -1 }
vwgts, hewgts, options are NULL
HMETIS_PartRecursive( nvtxs, nhedges, vwgts, eptr, eind, hewgts, nofParts, ubfactor, options, part, &edgecut );

Is there anything wrong with the setup?

The version is hmetis-1.5-linux.

Thanks a lot in advance.

mals.

RE: If I recall, the numbering

If I recall, the numbering of the cells starts from 0 and not from 1. That is the eind's should be decreased by 1. (just going from memory as I'm on the road).

RE: Problem in pre-assignment

Thanks for your prompt reply.

Yes, you are right. I double checked the manual, the vertex number should be starting from 0. I also realize that options shouldn't be NULL. options[0]=0 leads to default option values instead of options=NULL.

The next step is to try pre-assignment. I want the vertex 0 is preassigned to partition 0, but I got the error "free(): invalid pointer 0x80812c0!". The setup is as below. All options are using default values except option[6]. It's set to 1 to enable pre-assignment. Is there anything wrong with it?

nvtxs = 3, nhedges = 3, nparts = 3, ubfactor = 20
eptr = { 0 2 4 6 }
eind = { 1 2 0 1 0 2 }
part = { 0 -1 -1 }
options[0] = 1; // enable option set
options[1] = 10; // Nruns - default
options[2] = 1; // CType - default
options[3] = 1; // RType - default
options[4] = 1; // Vcycle - default
options[5] = 0; // Reconst - default
options[6] = 1; // enable preassign
options[7] = -1; // random seed - default
options[8] = 0; // no debug info - default

mals.

RE: Are you passing the various

Are you passing the various arrays from a malloced space or from statically allocated memory?

RE: The array "part" is from

The array "part" is dynamiclly allocated memory. The code is as below,

main( )
{
int nvtxs = 3;
int nhedges = 3;
int* vwgts = 0;
int* eptr = 0;
int* eind = 0;
int* hewgts = 0;
int nofParts = 3;
int ubfactor = 20;
int* options = 0;
int* part = 0;
int edgecut = 0;

eptr = new int[4];
eptr[0] = 0;
eptr[1] = 2;
eptr[2] = 4;
eptr[3] = 6;

eind = new int[6];
eind[0] = 1;
eind[1] = 2;
eind[2] = 0;
eind[3] = 1;
eind[4] = 0;
eind[5] = 2;

options = new int[9];
options[0] = 1; // enable option set
options[1] = 10; // Nruns - default
options[2] = 1; // CType - default
options[3] = 1; // RType - default
options[4] = 1; // Vcycle - default
options[5] = 0; // Reconst - default
options[6] = 1; // enable preassign
options[7] = -1; // random seed - default
options[8] = 0; // no debug info - default*/

part = new int[3];
part[0] = 0;
part[1] = -1;
part[2] = -1;

HMETIS_PartRecursive( nvtxs, nhedges, vwgts, eptr, eind, hewgts, nofParts, ubfactor, options, part, &edgecut );

Thanks,
mals.

RE: This may be a C/C++ problem

This may be a C/C++ problem in the dynamic memory management. Try using hmetis from a C program and let me know if you are encountering the same problem.

RE: I ran into the same problem

I ran into the same problem after changing the code to C program. I did two experiments,

1. Replace "new" with "calloc" as below,
eptr = ( int* )calloc( 4, sizof( int ) );

2. Replace dynamically allocated memory with static array,
int eptr[4];

I still got the message: "free(): invalid pointer 0x8081250". But the result seems correct.

I use gcc on linux: the version is,
gcc (GCC) 3.2.3 20030502 (Red Hat Linux 3.2.3-14)

The compile command is "gcc main2.cc libhmetis.a".

Thanks,
mals