*: Replace usage of &vector[0] with vector.data()
We use &vector[0] in several places to get the pointer to vector data, but std::vector[i] states invariant that i must be < vector.size(). If the vector is not empty - then &vector[0] works ok. However if the vector is empty - then the invariant is broken. Normally it should not be a problem, since with empty vector we usually use (&vector[0], vector.size()) pair, and for empty vector its size is zero. In other words even if &vector[0] returns some not good pointer with zero size that data should never be accessed. But a build of libstdc++ could have asserts turned on and verify that i is actually < size. For example with default install on Fedora the following program with plain select() from golang import select select() crashes with assert triggered on the breakage of that invariant [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib64/libthread_db.so.1". /usr/include/c++/10/bits/stl_vector.h:1042: std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = golang::_selcase; _Alloc = std::allocator<golang::_selcase>; std::vector<_Tp, _Alloc>::reference = golang::_selcase&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]: Assertion '__builtin_expect(__n < this->size(), true)' failed. Program received signal SIGABRT, Aborted. 0x00007ffff7e22a25 in raise () from /lib64/libc.so.6 (gdb) bt #0 0x00007ffff7e22a25 in raise () from /lib64/libc.so.6 #1 0x00007ffff7e0b895 in abort () from /lib64/libc.so.6 #2 0x00007fffea638d6d in std::__replacement_assert (__condition=0x7fffea63ea88 "__builtin_expect(__n < this->size(), true)", __function=0x7fffea63eab8 "std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = golang::_selcase; _Alloc = std::allocator<golang::_selcase>; std::vector<_Tp, "..., __line=1042, __file=0x7fffea63ebe8 "/usr/include/c++/10/bits/stl_vector.h") at /usr/include/c++/10/x86_64-redhat-linux/bits/c++config.h:2552 #3 std::vector<golang::_selcase, std::allocator<golang::_selcase> >::operator[] (this=<synthetic pointer>, __n=0) at /usr/include/c++/10/bits/stl_vector.h:1042 #4 std::vector<golang::_selcase, std::allocator<golang::_selcase> >::operator[] (__n=0, this=<synthetic pointer>) at /usr/include/c++/10/bits/stl_vector.h:1040 #5 __pyx_pf_6golang_7_golang_6pyselect (__pyx_self=<optimized out>, __pyx_v_pycasev=<optimized out>) at golang/_golang.cpp:7930 #6 __pyx_pw_6golang_7_golang_7pyselect (__pyx_self=<optimized out>, __pyx_args=<optimized out>, __pyx_kwds=<optimized out>) at golang/_golang.cpp:7284 #7 0x00007ffff7bceeab in cfunction_call_varargs (func=<built-in function pyselect>, args=(), kwargs=0x0) at /usr/src/debug/python3-3.8.10-1.fc32.x86_64/Objects/call.c:743 ... -> Fix it all via replacing &vector[0] with vector.data() everywhere. No need to add new test since select() is used by test_blockforever() and running that test on Fedora was crashing as well. /reviewed-by @jerome /reviewed-at !22
Status | Job ID | Name | Coverage | ||||||
---|---|---|---|---|---|---|---|---|---|
External | |||||||||
passed |
#588987
external
|
Pygolang.UnitTest-Master.Python2 |
00:01:36
|
||||||
passed |
#549408
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:04:29
|
||||||
passed |
#549545
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:56
|
||||||
passed |
#549644
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:41
|
||||||
passed |
#549735
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:53
|
||||||
passed |
#549887
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:51
|
||||||
passed |
#550621
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:02:03
|
||||||
passed |
#550881
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:02:02
|
||||||
passed |
#551211
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:02:01
|
||||||
passed |
#551292
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:49
|
||||||
passed |
#551399
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:02:02
|
||||||
failed |
#551906
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:28
|
||||||
passed |
#552095
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:39
|
||||||
failed |
#553101
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:00:21
|
||||||
failed |
#553109
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:00:27
|
||||||
failed |
#553126
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:00:20
|
||||||
failed |
#553135
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:00:19
|
||||||
failed |
#553151
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:00:29
|
||||||
failed |
#553172
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:00:21
|
||||||
failed |
#553189
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:00:33
|
||||||
failed |
#553198
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:00:29
|
||||||
failed |
#553224
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:00:29
|
||||||
failed |
#553235
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:00:30
|
||||||
failed |
#553247
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:00:28
|
||||||
failed |
#553258
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:15:12
|
||||||
passed |
#553657
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:02:06
|
||||||
passed |
#553894
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:37
|
||||||
passed |
#553937
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:37
|
||||||
passed |
#553992
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:59
|
||||||
passed |
#554044
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:57
|
||||||
passed |
#554270
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:02:12
|
||||||
passed |
#554399
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:49
|
||||||
passed |
#554511
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:27
|
||||||
failed |
#554641
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:57
|
||||||
passed |
#554894
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:58
|
||||||
failed |
#555091
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:54
|
||||||
passed |
#555175
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:02:06
|
||||||
passed |
#555430
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:42
|
||||||
passed |
#555548
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:49
|
||||||
passed |
#555693
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:50
|
||||||
passed |
#555946
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:02:01
|
||||||
passed |
#556154
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:02:02
|
||||||
passed |
#556223
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:59
|
||||||
passed |
#556517
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:02:03
|
||||||
failed |
#556745
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:02:27
|
||||||
passed |
#556878
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:02:00
|
||||||
passed |
#557457
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:02:03
|
||||||
passed |
#557533
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:52
|
||||||
passed |
#557726
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:51
|
||||||
passed |
#557939
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:37:58
|
||||||
passed |
#558068
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:02:08
|
||||||
failed |
#558198
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:02:32
|
||||||
failed |
#558371
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:56
|
||||||
passed |
#558581
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:28:52
|
||||||
passed |
#558777
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:28
|
||||||
passed |
#559095
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:02:19
|
||||||
passed |
#559296
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:55
|
||||||
passed |
#561584
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:04:47
|
||||||
failed |
#563026
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:02:07
|
||||||
failed |
#564960
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:03:00
|
||||||
failed |
#567493
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:48
|
||||||
failed |
#567923
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:02:04
|
||||||
passed |
#568056
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:02:09
|
||||||
passed |
#568180
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:42
|
||||||
passed |
#576439
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:02:00
|
||||||
passed |
#578230
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:36
|
||||||
passed |
#578417
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:33
|
||||||
failed |
#578503
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:02:39
|
||||||
passed |
#578657
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:57
|
||||||
passed |
#578852
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:29
|
||||||
failed |
#579585
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:02:04
|
||||||
passed |
#580057
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:36
|
||||||
passed |
#580487
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:48
|
||||||
passed |
#580613
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:53
|
||||||
passed |
#580766
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:36
|
||||||
failed |
#580871
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:02:43
|
||||||
passed |
#581067
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:42
|
||||||
failed |
#581144
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:03:03
|
||||||
failed |
#581283
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:02:30
|
||||||
passed |
#581567
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:02:22
|
||||||
passed |
#581785
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:30
|
||||||
passed |
#581852
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:27
|
||||||
passed |
#582165
external
retried
|
Pygolang.UnitTest-Master.Python2 |
01:26:54
|
||||||
passed |
#582284
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:56:12
|
||||||
passed |
#582786
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:42
|
||||||
passed |
#582852
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:56
|
||||||
failed |
#583653
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:28
|
||||||
passed |
#583764
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:36
|
||||||
passed |
#583928
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:21
|
||||||
passed |
#586294
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:31
|
||||||
passed |
#586396
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:54
|
||||||
passed |
#586662
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:23
|
||||||
passed |
#586790
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:05:18
|
||||||
passed |
#586858
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:26
|
||||||
passed |
#586898
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:44
|
||||||
passed |
#586978
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:25
|
||||||
passed |
#587053
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:46
|
||||||
passed |
#588260
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:25
|
||||||
passed |
#588301
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:29
|
||||||
passed |
#588398
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:44
|
||||||
passed |
#588805
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:42
|
||||||
passed |
#588911
external
retried
|
Pygolang.UnitTest-Master.Python2 |
00:01:24
|
||||||