Why does accessing a `size_t` type variable in C++ cause a segmentation fault?
I’m currently writing a test that uses a RPC framework based on RDMA, the github repository is here:https://github.com/erpc-io/eRPC.git
And something strange occurred, segmentation fault happened when the function access a inner data structure of this framework.
I used GDB to see the trace, and it turned out that a size()
function that access a size_t
type variable free_index_
, and that’s where the segfault happened.
I think the implement of my test doesn’t matter a lot in this question, I just wonder why a size_t
can cause segfault.
Here’s the source code in this RPC framework(called eRPC), the free_index_
variable declaration is in the class FixedVector
: