rliang / libtsqubo

A header-only C/C++ library for solving QUBO problems through Tabu Search.
MIT License
1 stars 0 forks source link

segfault using test program #1

Open rbras opened 1 year ago

rbras commented 1 year ago

Hi

I tried to use your library but I received a Segmentation fault when executing the code in the README (I had to modify the call to tsqubo_instance_new because it needs a parameter.

The error was:

Program received signal SIGSEGV, Segmentation fault. 0x0000000000401b50 in comparedouble (q=0x418cb0, v=0x418df0, a=23, b=11) at /home/rbras/trabalho/projDiogo-2022/software/libtsqubo-master/tsqubo.h:227 227 return v[q->N[a]] < v[q->N[b]] || (v[q->N[a]] == v[q->N[b]] && q->N[a] < q->N[b]); Missing separate debuginfos, use: dnf debuginfo-install glibc-2.37-4.fc38.x86_64 libgcc-13.1.1-1.fc38.x86_64 libstdc++-13.1.1-1.fc38.x86_64 (gdb) bt

0 0x0000000000401b50 in comparedouble (q=0x418cb0, v=0x418df0, a=23, b=11)

at /home/rbras/trabalho/projDiogo-2022/software/libtsqubo-master/tsqubo.h:227

1 0x0000000000401c88 in ipq_sift_up (q=0x418cb0, dx=0x418df0,

compare=0x401b10 <compare_double(ipq const*, void const*, size_t, size_t)>, k=11)
at /home/rbras/trabalho/projDiogo-2022/software/libtsqubo-master/tsqubo.h:235

2 0x00000000004025ec in tsqubo_flip_current (ts=0x418c50, i=1)

at /home/rbras/trabalho/projDiogo-2022/software/libtsqubo-master/tsqubo.h:411

3 0x00000000004029f8 in tsqubo_iterate (ts=0x418c50, ttc=10)

at /home/rbras/trabalho/projDiogo-2022/software/libtsqubo-master/tsqubo.h:479

4 0x0000000000402a4b in tsqubo_iterate_cutoff (ts=0x418c50, ttc=10, cutoff=5)

at /home/rbras/trabalho/projDiogo-2022/software/libtsqubo-master/tsqubo.h:493

5 0x0000000000402b69 in main () at test1.cpp:20

(gdb) print q $1 = (const ipq ) 0x418cb0 (gdb) print q $2 = {N = 0x418e30, I = 0x418e50, size = 18446744073709551614}

Best regards,

rliang commented 1 year ago

Thanks, I fixed it in the README.

Did you get a segmentation fault before or after adding the parameter value?

If before, then most likely the segmentation fault was because the missing parameter was garbage memory, thus making it allocate a wrong amount of memory.

rbras commented 1 year ago

Citando rliang @.***>:

Thanks, I fixed it in the README.

Did you get a segmentation fault before or after adding the parameter value?

After, it did not compile without the parameter. I used a value of 100.

Best regards,

If before, then most likely the segmentation fault was because the
missing parameter was garbage memory, thus making it allocate a
wrong amount of memory.

-- Raul Brás ISEG - Lisbon School of Economics & Management Universidade de Lisboa (+351)213922825 www.iseg.ulisboa.pt

rbras commented 1 year ago

Still crashes in the same place. Examining the variables we have: q={N = 0x418590, I = 0x4185b0, size = 18446744073709551614} v=2 q->N[a]=59841 q->N[b]=0 v[q->N[b]]=2 v[q->N[a]] --> Segmentation fault

I compiled using C++. Compiler version: gcc version 13.1.1 20230426 (Red Hat 13.1.1-1) (GCC)