Sunrisepeak / dstruct

🔥An easy-to-port/learn/use C++ data structure template library | 一个易于移植/使用/学习且结构简洁的数据结构模板库
https://github.com/Sunrisepeak/DStruct
Apache License 2.0
40 stars 2 forks source link

TODO: 复杂对象 & 指针 类型测试 #7

Closed Sunrisepeak closed 4 months ago

Sunrisepeak commented 1 year ago

由于基础类型只能验证基本功能, 往往在边界情况不会发生crash 后续需要使用复杂类型及对应的指针进行验证

Sunrisepeak commented 1 year ago

4e1952116ab561f5be989bd79f7a7362c7549912

这个版本的 Deque 存在 边界扩容问题(复现: DSVisual 控件 Widget接口类 指针)


for (int i = 0; i < 34; i++) {
  deque.push_back
  deque.pop_front
}

i = 33 时 begin 迭代器边界情况 触发 resize 扩容问题

原因扩容后没有更新 _mBegin 迭代器 中对应的 _mCurr

Sunrisepeak commented 1 year ago

报错信息

Type "apropos word" to search for commands related to "word"...
Reading symbols from /home/speak/workspace/github/DSVisual/build/linux/x86_64/release/dsvisual_array...
(gdb) 
(gdb) r
Starting program: /home/speak/workspace/github/DSVisual/build/linux/x86_64/release/dsvisual_array 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault.
0x0000555555559f68 in dsvisual::Window::render (this=0x7fffffffccb0) at ./dsvisual.hpp:140
140                 w->draw();
(gdb) bt
#0  0x0000555555559f68 in dsvisual::Window::render (this=0x7fffffffccb0) at ./dsvisual.hpp:140
#1  0x0000555555559921 in main () at examples/array.cpp:19
(gdb) info all-registers 
rax            0x0                 0
rbx            0x55555560c7d0      93824992987088
rcx            0x0                 0
rdx            0x1                 1
rsi            0x40                64
rdi            0x7fffffffccb0      140737488342192
rbp            0x7fffffffcc90      0x7fffffffcc90
rsp            0x7fffffffcc40      0x7fffffffcc40
r8             0x0                 0
r9             0x55555560e1eb      93824992993771
r10            0x2                 2
r11            0x7fffffffcac0      140737488341696
r12            0x555555559450      93824992253008
r13            0x7fffffffce70      140737488342640
r14            0x0                 0
r15            0x0                 0
rip            0x555555559f68      0x555555559f68 <dsvisual::Window::render()+358>
eflags         0x10202             [ IF RF ]
--Type <RET> for more, q to quit, c to continue without paging--
cs             0x33                51
ss             0x2b                43
ds             0x0                 0
es             0x0                 0
fs             0x0                 0
gs             0x0                 0
st0            0                   (raw 0x00000000000000000000)
st1            0                   (raw 0x00000000000000000000)
st2            0                   (raw 0x00000000000000000000)
st3            0                   (raw 0x00000000000000000000)
st4            0                   (raw 0x00000000000000000000)
st5            0                   (raw 0x00000000000000000000)
st6            0                   (raw 0x00000000000000000000)
st7            0                   (raw 0x00000000000000000000)
fctrl          0x37f               895
fstat          0x0                 0
ftag           0xffff              65535
fiseg          0x0                 0
fioff          0x0                 0
foseg          0x0                 0
fooff          0x0                 0
fop            0x0                 0
mxcsr          0x1fa0              [ PE IM DM ZM OM UM PM ]
pkru           0x55555554          1431655764
ymm0           {v8_float = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_double = {0x0, 0x0, 0x0, 0x0}, v32_int8 = {0x0 <repeats 32 times>}, v16_int16 = {0x0 <repeats 16 times>}, v8_int32 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int64 = {0x0, 0x0, 0x0, 0x0}, v2_int128 = {0x0, 0x0}}
ymm1           {v8_float = {0x40, 0x4f, 0x1c8, 0x1cb, 0x0, 0x0, 0x0, 0x0}, v4_double = {0x7800010a000, 0x7fffffffffffffff, 0x0, 0x0}, v32_int8 = {0x0, 0x0, 0x80, 0x42, 0x0, 0x0, 0x9e, 0x42, 0x0, 0x0, 0xe4, 0x43, 0x0, 0x80, 0xe5, 0x43, 0x0 <repeats 16 times>}, v16_int16 = {0x0, 0x4280, 0x0, 0x429e, 0x0, 0x43e4, 0x8000, 0x43e5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v8_int32 = {0x42800000, 0x429e0000, 0x43e40000, 0x43e58000, 0x0, 0x0, 0x0, 0x0}, v4_int64 = {0x429e000042800000, 0x43e5800043e40000, 0x0, 0x0}, v2_int128 = {0x43e5800043e40000429e000042800000, 0x0}}
ymm2           {v8_float = {0x40, 0x4f, 0x1c8, 0x1cb, 0x0, 0x0, 0x0, 0x0}, v4_double = {0x7800010a000, 0x7fffffffffffffff, 0x0, 0x0}, v32_int8 = {0x0, 0x0, 0x80, 0x42, 0x0, 0x0, 0x9e, 0x42, 0x0, 0x0, 0xe4, 0x43, 0x0, 0x80, 0xe5, 0x43, 0x0 <repeats 16 times>}, v16_int16 = {0x0, 0x4280, 0x0, 0x429e, 0x0, 0x43e4, 0x8000, 0x43e5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v8_int32 = {0x42800000, 0x429e0000, 0x43e40000, 0x43e58000, 0x0, 0x0, 0x0, 0x0}, v4_int64 = {0x429e000042800000, 0x43e5800043e40000, 0x0, 0x0}, v2_int128 = {0x43e5800043e40000429e000042800000, 0x0}}
ymm3           {v8_float = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_double = {0x0, 0x0, 0x0, 0x0}, v32_int8 = {0x1, 0x0 <repeats 11 times>, 0x81, 0x0 <repeats 19 times>}, v16_int16 = {0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x81, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v8_int32 = {0x1, 0x0, 0x0, 0x81, 0x0, 0x0, 0x0, 0x0}, v4_int64 = {0x1, 0x8100000000, 0x0, 0x0}, v2_int128 = {0x81000000000000000000000001, 0x0}}
ymm4           {v8_float = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_double = {0x0, 0x0, 0x0, 0x0}, v32_int8 = {0x0 <repeats 32 times>}, v16_int16 = {0x0 <repeats 16 times>}, v8_int32 = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, v4_int64 = {0x0, 0x0, 0x0, 0x0}, v2_int128 = {0x0, 0x0}}
--Type <RET> for more, q to quit, c to continue without paging--q
Quit
(gdb) p i
$1 = 33
(gdb) 
Sunrisepeak commented 4 months ago

见 #57