mrirecon / bart

BART: Toolbox for Computational Magnetic Resonance Imaging
https://mrirecon.github.io/bart/
BSD 3-Clause "New" or "Revised" License
295 stars 163 forks source link

./test_iter segfaults on WSL #260

Closed jtamir closed 2 years ago

jtamir commented 3 years ago

I think it is related to iter_irgnm. Tested on bart 0.6.00 and WSL Ubuntu 18.04

hcmh commented 3 years ago

Backtrace for this is:

Thread 1 "test_iter" received signal SIGSEGV, Segmentation fault.
0x00007ffffffedce0 in ?? ()
(gdb) bt
#0  0x00007ffffffedce0 in ?? ()
#1  0x000000000800f089 in fista (maxiter=10, epsilon=<optimized out>, tau=<optimized out>, N=N@entry=48,
    vops=0x8267760 <cpu_iter_ops>, ist_continuation=ist_continuation@entry=0x7ffffffedce0, op=..., thresh=..., x=0x846eec0,
    b=0x84778e0, monitor=0x0) at /home/cholme/git/bart-0.6.00/src/iter/italgos.c:229
#2  0x000000000800d989 in iter2_fista (_conf=<optimized out>, normaleq_op=0x846e0d0, D=<optimized out>,
    prox_ops=<optimized out>, ops=<optimized out>, biases=<optimized out>, xupdate_op=0x0, size=48, image=0x846eec0,
    image_adj=0x84778e0, monitor=0x0) at /home/cholme/git/bart-0.6.00/src/iter/iter2.c:260
#3  0x0000000008014263 in itop_apply (_data=0x846fcf0, alpha=1, dst=0x846eec0, src=0x84778e0)
    at /home/cholme/git/bart-0.6.00/src/iter/itop.c:68
#4  0x000000000801d3e6 in operator_generic_apply_unchecked (args=0x7ffffffede30, N=3, op=0x846e2f0)
    at /home/cholme/git/bart-0.6.00/src/num/ops.c:537
#5  combi_apply (_data=0x84771c0, N=5, args=0x7ffffffede30) at /home/cholme/git/bart-0.6.00/src/num/ops.c:1128
#6  0x000000000801ddd3 in operator_generic_apply_unchecked (args=0x7ffffffede30, N=5, op=0x8477200)
    at /home/cholme/git/bart-0.6.00/src/num/ops.c:537
#7  link_apply (_data=0x84774a0, N=3, args=0x7ffffffedee0) at /home/cholme/git/bart-0.6.00/src/num/ops.c:1353
#8  0x0000000008023cb7 in operator_p_apply_unchecked (_op=<optimized out>, mu=<optimized out>, dst=<optimized out>,
    src=<optimized out>) at /home/cholme/git/bart-0.6.00/src/num/ops_p.c:262
#9  0x000000000800fb28 in iter_op_p_call (src=0x8477740, dst=0x846eec0, rho=1, op=...)
    at /home/cholme/git/bart-0.6.00/src/iter/italgos.h:60
#10 irgnm2 (iter=1, alpha=1, alpha_min=0, alpha_min0=alpha_min0@entry=0, redu=<optimized out>, N=N@entry=48, M=M@entry=48,
    vops=0x8267760 <cpu_iter_ops>, op=..., der=..., lsqr=..., x=0x846eec0, xref=0x0, y=0x846ec50, callback=..., monitor=0x0)
    at /home/cholme/git/bart-0.6.00/src/iter/italgos.c:493
#11 0x0000000008012009 in iter4_irgnm2 (_conf=_conf@entry=0x7ffffffee1a0, nlop=nlop@entry=0x8471420, N=48,
    dst=dst@entry=0x846eec0, ref=ref@entry=0x0, M=M@entry=48, src=0x846ec50, lsqr=0x84774c0, cb=...)
    at /home/cholme/git/bart-0.6.00/src/iter/iter4.c:221
#12 0x000000000800c31c in test_iter_irgnm_l1 () at utests/test_iter.c:272
#13 call_test_iter_irgnm_l1 () at utests/test_iter.c:294
#14 0x000000000800b19c in main (argc=<optimized out>, argv=0x7ffffffee388) at utests/utest.c:51

Also happens on bart master for ./test_iter

./test_moba on master also segfaults, with backtrace:

Thread 1 "test_moba" received signal SIGSEGV, Segmentation fault.
0x00007ffffffed828 in ?? ()
(gdb) bt
#0  0x00007ffffffed828 in ?? ()
#1  0x000000000806b253 in quicksort (N=N@entry=2, ord=ord@entry=0x7ffffffed760, cmp=cmp@entry=0x7ffffffed828)
    at /home/cholme/git/bart/src/misc/misc.c:270
#2  0x000000000805bc3e in compute_permutation (strs=<optimized out>, ord=<optimized out>, N=<optimized out>)
    at /home/cholme/git/bart/src/num/optimize.c:201
#3  optimize_dims (D=D@entry=3, N=N@entry=16, dims=dims@entry=0x7ffffffeda60, strs=strs@entry=0x7ffffffed8b0)
    at /home/cholme/git/bart/src/num/optimize.c:370
#4  0x000000000805c7b4 in optimized_nop (N=N@entry=3, io=io@entry=1, D=16, dim=0x848d9f0, nstr=nstr@entry=0x7ffffffedc60,
    nptr=nptr@entry=0x7ffffffedc80, sizes=0x7ffffffedc40) at /home/cholme/git/bart/src/num/optimize.c:651
#5  0x000000000803200a in optimized_threeop_oii (too=0x7ffffffedca8, sizes=0x7ffffffedc40, iptr2=0x8498670, istr2=0x848dd50,
    iptr1=0x848f610, istr1=<optimized out>, optr=0x8490630, ostr=0x848dc30, dim=<optimized out>, D=<optimized out>)
    at /home/cholme/git/bart/src/num/flpmath.c:147
#6  make_z3op (offset=<optimized out>, D=<optimized out>, dim=<optimized out>, ostr=0x848dc30, optr=0x8490630,
    istr1=<optimized out>, iptr1=0x848f610, istr2=0x848dd50, iptr2=0x8498670) at /home/cholme/git/bart/src/num/flpmath.c:256
#7  0x0000000008032a28 in md_zmul2 (D=16, dim=0x848d9f0, ostr=0x848dc30, optr=0x8490630, istr1=0x848dba0, iptr1=0x848f610,
    istr2=0x848dd50, iptr2=0x8498670) at /home/cholme/git/bart/src/num/flpmath.c:536
#8  0x000000000800f883 in T1_fun (_data=0x848d8b0, dst=0x848a090, src=0x848c0a0) at /home/cholme/git/bart/src/moba/T1fun.c:85
#9  0x00000000080290d0 in operator_generic_apply_unchecked (args=0x7ffffffedfc0, N=2, op=0x8499290)
    at /home/cholme/git/bart/src/num/ops.c:584
#10 operator_apply_unchecked (src=0x848c0a0, dst=0x848a090, op=0x8499290) at /home/cholme/git/bart/src/num/ops.c:594
#11 operator_apply2 (src=0x848c0a0, istrs=0x7ffffffedf10, idims=0x7ffffffee160, IN=16, dst=0x848a090, ostrs=0x7ffffffede80,
    odims=0x7ffffffee0e0, ON=16, op=0x8499290) at /home/cholme/git/bart/src/num/ops.c:603
#12 operator_apply (op=0x8499290, ON=ON@entry=16, odims=odims@entry=0x7ffffffee0e0, dst=dst@entry=0x848a090, IN=IN@entry=16,
    idims=idims@entry=0x7ffffffee160, src=0x848c0a0) at /home/cholme/git/bart/src/num/ops.c:608
#13 0x000000000801aadb in nlop_apply (op=op@entry=0x84986a0, ON=ON@entry=16, odims=odims@entry=0x7ffffffee0e0,
    dst=dst@entry=0x848a090, IN=IN@entry=16, idims=idims@entry=0x7ffffffee160, src=0x848c0a0)
    at /home/cholme/git/bart/src/nlops/nlop.c:342
#14 0x000000000800dc20 in test_nlop_T1fun () at utests/test_moba.c:53
#15 0x000000000800d85d in main (argc=<optimized out>, argv=0x7ffffffee398) at utests/utest.c:51

Both of these are places where we use a nested function passed through a function pointer.

jtamir commented 2 years ago

No longer an issue with WSL 2