rodarima / cpic

Particle in Cell simulation of plasma in C
GNU General Public License v3.0
1 stars 1 forks source link

plist_close_remove: Assertion `p->magic[iv] == MAGIC_PARTICLE' failed #8

Closed rodarima closed 4 years ago

rodarima commented 4 years ago
cpic: src/plist.c:353: void plist_sanity_check(plist_t *): Assertion `p->magic[iv] == MAGIC_PARTICLE' failed.

Thread 1 "cpic" received signal SIGABRT, Aborted.
0x00007ffff755cce5 in raise () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007ffff755cce5 in raise () from /usr/lib/libc.so.6
#1  0x00007ffff7546857 in abort () from /usr/lib/libc.so.6
#2  0x00007ffff7546727 in __assert_fail_base.cold () from /usr/lib/libc.so.6
#3  0x00007ffff7555426 in __assert_fail () from /usr/lib/libc.so.6
#4  0x000055555556777c in plist_sanity_check (l=0x55555571bf78) at src/plist.c:353
#5  0x00005555555681a0 in plist_close_remove (l=0x55555571bf78) at src/plist.c:1178
#6  0x0000555555567c5d in plist_close (l=0x55555571bf78) at src/plist.c:1213
#7  0x00005555555597ce in collect_pass (ex=0x7fffffffdcc0, dim=0) at src/comm_plasma.c:514
#8  0x0000555555559547 in collect_pset (c=0x55555571a360, set=0x55555571bf70, dim=0) at src/comm_plasma.c:566
#9  0x00005555555592e7 in collect_pchunk (c=0x55555571a360, dim=0) at src/comm_plasma.c:590
#10 0x0000555555558ce0 in collect_plasma (sim=0x555555717560, dim=0) at src/comm_plasma.c:614
#11 0x000055555555891b in comm_plasma_x (sim=0x555555717560, global_exchange=1) at src/comm_plasma.c:847
#12 0x0000555555558718 in comm_plasma (sim=0x555555717560, global_exchange=1) at src/comm_plasma.c:1103
#13 0x0000555555565987 in particle_comm_initial (sim=0x555555717560) at src/particle.c:266
#14 0x000055555556c736 in sim_pre_step (sim=0x555555717560) at src/sim.c:196
#15 0x000055555556bd89 in sim_init (conf=0x7fffffffe1e0, quiet=0) at src/sim.c:283
#16 0x000055555555cc44 in main (argc=2, argv=0x7fffffffe338) at src/cpic.c:169
rodarima commented 4 years ago

Last block only contains garbage, but is shown as if it was full:

(gdb) p b
$6 = (pblock_t *) 0x7fff6f400000
(gdb) p l->b
$7 = (struct pblock *) 0x7ffefc000000
(gdb) p l->b->prev
$8 = (struct pblock *) 0x7fff6f400000
(gdb) p l->b->prev[0]
$9 = {{{n = 1024, npacks = 256, nfpacks = 256, next = 0x0, prev = 0x7fff6f600000}, 
    _pad = "\000\004\000\000\000\000\000\000\000\001\000\000\000\000\000\000\000\001", '\000' <repeats 16 times>, "`o\377\177", '\000' <repeats 89 times>}, 
  p = 0x7fff6f400080}
(gdb) p l->b->prev->p[0]
$10 = {magic = {3735941133, 3735941133, 3735941133, 3735941133}, i = {1162564, 1162580, 1162596, 1162628}, r = {{47.305835723876953, 28.54927858710289, 
      23.520331770181656, 33.882113993167877}, {43.183233976364136, 8.1541470587253571, 44.026550322771072, 59.993576109409332}, {0, 0, 0, 0}}, u = {{0, 0, 
      0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, E = {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}, B = {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0}}}
(gdb) p/x l->b->prev->p[0]
$11 = {magic = {0xdeadf00d, 0xdeadf00d, 0xdeadf00d, 0xdeadf00d}, i = {0x11bd44, 0x11bd54, 0x11bd64, 0x11bd84}, r = {{0x2f, 0x1c, 0x17, 0x21}, {0x2b, 0x8, 
      0x2c, 0x3b}, {0x0, 0x0, 0x0, 0x0}}, u = {{0x0, 0x0, 0x0, 0x0}, {0x0, 0x0, 0x0, 0x0}, {0x0, 0x0, 0x0, 0x0}}, E = {{0x0, 0x0, 0x0, 0x0}, {0x0, 0x0, 0x0, 
      0x0}, {0x0, 0x0, 0x0, 0x0}}, B = {{0x0, 0x0, 0x0, 0x0}, {0x0, 0x0, 0x0, 0x0}, {0x0, 0x0, 0x0, 0x0}}}

Is this a corner case?

rodarima commented 4 years ago

Looks like is a corner case:

. . . . . . B is now at ip=2 gip=14594 b=0x7fff6f400000
. . . . . . B: cleaning ppack at ip=2
. . . . . . B: moving to the previous ppack
. . . . . . B is now at ip=1 gip=14593 b=0x7fff6f400000
. . . . . . B: cleaning ppack at ip=1
. . . . . . B: moving to the previous ppack
. . . . . . B is now at ip=0 gip=14592 b=0x7fff6f400000
. . . . . . B: cleaning ppack at ip=0
. . . . . . B: enabled=4
. . . . . . B: 11 particles out
. . . . . . --- produce_extra_B ends ---
. . . . . . --- produce_holes_A begins ---
. . . . . . A: 0 particles out
. . . . . . --- produce_holes_A ends ---
. . . . . . --- fill_holes begins ---
. . . . . . 1 holes filled
. . . . . . --- fill_holes ends ---
. . . . . . --- produce_extra_B begins ---
. . . . . . B is at ip=0 gip=14592 b=0x7fff6f400000
. . . . . . B: moving to the previous ppack
. . . . . . B: cannot step anymore, stop
. . . . . . B: enabled=0
. . . . . . B: 0 particles out
. . . . . . --- produce_extra_B ends ---
. . . . . . --- produce_holes_A begins ---
. . . . . . A: cannot step anymore, stop
. . . . . . A: 0 particles out
. . . . . . --- produce_holes_A ends ---
...
(gdb) p l->nblocks * l->max_packs 
$12 = 14592

Hypothesis: d

In remod_end we are returning the REMOVE window, but then considering the w->b of the remove window to be the last block of the list. The MODIFY window, which is full, must be used instead.