Autobatching fails: exec.cc:646 SIGSEGV, abptr == 0 but active_batched[abptr-1] accessed
- Dominant language
- C++
- Stars
- 3.4k
- Forks
- 701
- PR merge metrics
- No merged PRs in 30d
Description
I'm getting a SIGSEGV when using auto batching. It works for a while and then this occurs:
```
Program received signal SIGSEGV, Segmentation fault.
0x00007ffff63bea58 in dynet::BatchedExecutionEngine::incremental_forward_no_update (this=0x5555597a24b0, upto=1037, autobatch_strategy=1)
at dynet/dynet/exec.cc:646
646 *it = active_batched[abptr - 1];
(gdb) bt
#0 0x00007ffff63bea58 in dynet::BatchedExecutionEngine::incremental_forward_no_update (this=0x5555597a24b0, upto=1037, autobatch_strategy=1)
at dynet/dynet/exec.cc:646
#1 0x00007ffff63c0aef in dynet::BatchedExecutionEngine::incremental_forward (this=0x5555597a24b0, i=1037) at /home/mpetri/dev/dynet/dynet/exec.cc:918
#2 0x00007ffff63c0c2e in dynet::BatchedExecutionEngine::backward (this=0x5555597a24b0, from_where=1037, full=false) at dynet/dynet/exec.cc:933
#3 0x00007ffff63ad54b in dynet::ComputationGraph::backward (this=0x7fffffffd3c0, last=..., full=false) at dynet/dynet/dynet.cc:403
#4 0x000055555563dbbb in create_lm (cst=..., vocab=..., args=...) at lm.hpp:193
#5 0x000055555563e892 in main (argc=3, argv=0x7fffffffe298) at /home/mpetri/dev/dynet/create_cst_nn_lm.cpp:60
(gdb) list
641 abptr = active_batched[curr_prof];
642 assert(abptr != (VariableIndex)0);
643 my_batch.ids.resize(active_batched[curr_prof+uptop1]);
644 for (auto it = my_batch.ids.rbegin();
645 it != my_batch.ids.rend(); ++it) {
646 *it = active_batched[abptr - 1];
647 abptr = active_batched[abptr];
648 }
649 active_batched[curr_prof] = 0;
650 active_batched[curr_prof + uptop1] = 0;
(gdb) p abptr
$1 = 0
(gdb) p active_batched
$4 = std::vector of length 3648,
capacity 4152 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3647, 0, 0, 3475, 0,...}
```
so `active_batched[-1]` is accessed. Not sure what other information I can provide.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in dynet/exec.cc at incremental_forward_no_update, especially the active_batched handling around line 646, and trace its callers through incremental_forward and backward. Reproduce with the auto-batching path used by create_cst_nn_lm.cpp; done means the execution completes without accessing active_batched[-1] or otherwise triggering this SIGSEGV.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend, machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100