Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

terminate called after throwing an instance of 'std::out_of_range' #44

Open
Pocketkid2 opened this issue Jun 28, 2022 · 4 comments
Open

Comments

@Pocketkid2
Copy link

When running nextpnr-xilinx targeting a basys3 board like so:
nextpnr-xilinx --chipdb ../xc7a35t.bin --xdc ../basys3_nextpnr.xdc --json pong.json --write pong.routed.json --fasm pong.fasm --log nextpnr.log

I get this error:
terminate called after throwing an instance of 'std::out_of_range' what(): vector::_M_range_check: __n (which is 2) >= this->size() (which is 0)

This seems like the same thing that is seen in this issue, but I'm not sure how to locate a stack trace and figure out what's going on.

My constraints file (basys3_nextpnr.xdc) is here

@marzoul
Copy link
Contributor

marzoul commented Sep 10, 2024

I have the same issue.
Using Archlinux, a debug package is created when compiling from sources. So I installed it and got the stacktrace :

Info: Packing DSPs..
Info:     Created 35 DSP48E1_DSP48E1 cells from:
Info:             35x DSP48E1
terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 1) >= this->size() (which is 1)

Program received signal SIGABRT, Aborted.
0x00007ffff79b63f4 in ?? () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007ffff79b63f4 in ?? () from /usr/lib/libc.so.6
#1  0x00007ffff795d120 in raise () from /usr/lib/libc.so.6
#2  0x00007ffff79444c3 in abort () from /usr/lib/libc.so.6
#3  0x00007ffff7c97b2c in __gnu_cxx::__verbose_terminate_handler () at /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/vterminate.cc:95
#4  0x00007ffff7cadffa in __cxxabiv1::__terminate (handler=<optimized out>) at /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:48
#5  0x00007ffff7c9752a in std::terminate () at /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/eh_terminate.cc:58
#6  0x00007ffff7cae2b6 in __cxxabiv1::__cxa_throw (obj=<optimized out>, tinfo=0x7ffff7e76dc0 <typeinfo for std::out_of_range>, dest=0x7ffff7cc5810 <std::out_of_range::~out_of_range()>) at /usr/src/debug/gcc/gcc/libstdc++-v3/libsupc++/eh_throw.cc:98
#7  0x00007ffff7c9b423 in std::__throw_out_of_range_fmt (__fmt=__fmt@entry=0x5555556f9180 "vector::_M_range_check: __n (which is %zu) >= this->size() (which is %zu)") at /usr/src/debug/gcc/gcc/libstdc++-v3/src/c++11/functexcept.cc:101
#8  0x000055555557ddf0 in std::vector<nextpnr_xilinx::indexed_store<nextpnr_xilinx::PortRef>::slot, std::allocator<nextpnr_xilinx::indexed_store<nextpnr_xilinx::PortRef>::slot> >::_M_range_check (this=0x55556139d4b0, __n=<optimized out>)
    at /usr/include/c++/14.2.1/bits/stl_vector.h:1160
#9  std::vector<nextpnr_xilinx::indexed_store<nextpnr_xilinx::PortRef>::slot, std::allocator<nextpnr_xilinx::indexed_store<nextpnr_xilinx::PortRef>::slot> >::at (this=0x55556139d4b0, __n=<optimized out>) at /usr/include/c++/14.2.1/bits/stl_vector.h:1182
#10 nextpnr_xilinx::indexed_store<nextpnr_xilinx::PortRef>::at (this=0x55556139d4b0, idx=...) at /usr/src/debug/nextpnr-xilinx-git/nextpnr-xilinx/common/kernel/indexed_store.h:165
#11 nextpnr_xilinx::indexed_store<nextpnr_xilinx::PortRef>::iterator::operator* (this=<optimized out>, this=<optimized out>) at /usr/src/debug/nextpnr-xilinx-git/nextpnr-xilinx/common/kernel/indexed_store.h:202
#12 operator() (__closure=<synthetic pointer>, ni=0x55556139d490, port="PCOUT47") at /usr/src/debug/nextpnr-xilinx-git/nextpnr-xilinx/xilinx/pack_dsp_xc7.cc:34
#13 nextpnr_xilinx::XC7Packer::walk_dsp (this=this@entry=0x7fffffffbb90, root=<optimized out>, current_cell=<optimized out>, constr_z=constr_z@entry=25) at /usr/src/debug/nextpnr-xilinx-git/nextpnr-xilinx/xilinx/pack_dsp_xc7.cc:47
#14 0x00005555556a0502 in nextpnr_xilinx::XC7Packer::pack_dsps (this=0x7fffffffbb90) at /usr/src/debug/nextpnr-xilinx-git/nextpnr-xilinx/xilinx/pack_dsp_xc7.cc:158
#15 0x0000555555691e32 in nextpnr_xilinx::Arch::pack (this=0x55555576ba30) at /usr/src/debug/nextpnr-xilinx-git/nextpnr-xilinx/xilinx/pack.cc:904
#16 0x00005555556d402b in nextpnr_xilinx::CommandHandler::executeMain(std::unique_ptr<nextpnr_xilinx::Context, std::default_delete<nextpnr_xilinx::Context> >) [clone .constprop.0] (this=this@entry=0x7fffffffc5c0, ctx=std::unique_ptr<nextpnr_xilinx::Context> = {...})
    at /usr/src/debug/nextpnr-xilinx-git/nextpnr-xilinx/common/kernel/command.cc:452
#17 0x000055555558940f in nextpnr_xilinx::CommandHandler::exec (this=0x7fffffffc5c0) at /usr/src/debug/nextpnr-xilinx-git/nextpnr-xilinx/common/kernel/command.cc:549
#18 main (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/nextpnr-xilinx-git/nextpnr-xilinx/xilinx/main.cc:91
(gdb)

The design is non-trivial, around 10k LUTs + BRAMs + DSPs.
In case the above stacktrace is not enough to find the issue I'll provide it as an archive somewhere.

@marzoul
Copy link
Contributor

marzoul commented Sep 10, 2024

The code is weird.
I looked at involved source files pack_dsp_xc7.cc and indexed_store.h.
I don't think that line (pack_dsp_xc7.cc:34) is supposed to work in the first place (and/or extremely misleading coding style) :
PortRef& user = *ni->users.end();

@marzoul
Copy link
Contributor

marzoul commented Sep 10, 2024

Experiment : I added a rbegin() method to class indexed_store and replaced calls from pack_dsp_xc7.cc accordingly. The crash seems gone (but no guarantee I've done the right thing).

However I get a crash later in mapping LUTRAM-related cells :
ERROR: Unable to place cell 'user_inst.i_norm3.gen_par_n1_gen_mem_ram.0.9.genblk1.genblk1[1].genblk1.slice', no BELs remaining to implement cell type 'RAM128X1S'
(unrelated issue, just to say that the proposed fix would not make every design pass)

@marzoul
Copy link
Contributor

marzoul commented Sep 10, 2024

To track progress/discussions, I opened the pull request to fix this for nextpnr-himbaechel:
YosysHQ/nextpnr#1361

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants