Skip to content

Commit 05ce5c1

Browse files
committed
test: Add "infer" CI check to github, remove from circle.
This now uses our own built image with the current master of infer.
1 parent 814c12a commit 05ce5c1

File tree

10 files changed

+87
-86
lines changed

10 files changed

+87
-86
lines changed

.circleci/config.yml

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ workflows:
1616
# Static analysis
1717
- clang-analyze
1818
- cpplint
19-
- infer
2019
- static-analysis
2120

2221
jobs:
@@ -102,27 +101,6 @@ jobs:
102101
- run: git submodule update --init --recursive
103102
- run: CC=clang .circleci/cmake-ubsan
104103

105-
infer:
106-
working_directory: ~/work
107-
docker:
108-
- image: toxchat/infer
109-
110-
steps:
111-
- run: *apt_install
112-
- checkout
113-
- run: git submodule update --init --recursive
114-
- run: infer --no-progress-bar -- cc
115-
auto_tests/auto_test_support.c
116-
auto_tests/lossless_packet_test.c
117-
testing/misc_tools.c
118-
toxav/*.c
119-
toxcore/*.c
120-
toxcore/*/*.c
121-
toxencryptsave/*.c
122-
third_party/cmp/*.c
123-
-lpthread
124-
$(pkg-config --cflags --libs libsodium opus vpx)
125-
126104
static-analysis:
127105
working_directory: ~/work
128106
docker:

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
analysis:
1717
strategy:
1818
matrix:
19-
tool: [autotools, clang-tidy, compcert, cppcheck, doxygen, misra, tcc, tokstyle]
19+
tool: [autotools, clang-tidy, compcert, cppcheck, doxygen, infer, misra, tcc, tokstyle]
2020
runs-on: ubuntu-latest
2121
steps:
2222
- name: Set up Docker Buildx

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,5 @@ cscope.files
9393
# rpm
9494
tox.spec
9595

96+
/infer
9697
.idea/

other/analysis/run-infer

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6d2321d58fa948279b28ae28a888672164eadaa985c43ce99ed0b71a69033c5c /usr/local/bin/tox-bootstrapd
1+
870f1e19aa3f3f802c7e53af3848df6a0f7af9ad4c98213aa1578fa325b30fad /usr/local/bin/tox-bootstrapd

other/docker/infer/Dockerfile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
FROM toxchat/infer:latest
2+
3+
COPY toxav/ /work/c-toxcore/toxav/
4+
COPY toxcore/ /work/c-toxcore/toxcore/
5+
COPY toxencryptsave/ /work/c-toxcore/toxencryptsave/
6+
COPY third_party/ /work/c-toxcore/third_party/
7+
RUN infer capture -- clang++ -fsyntax-only \
8+
$(pkg-config --cflags libconfig libsodium opus vpx) \
9+
/work/c-toxcore/toxav/*.c \
10+
/work/c-toxcore/toxcore/*.c \
11+
/work/c-toxcore/toxcore/*/*.c \
12+
/work/c-toxcore/toxencryptsave/*.c
13+
RUN ["infer", "analyze",\
14+
"--report-console-limit", "100",\
15+
"--jobs", "8",\
16+
"--no-bufferoverrun",\
17+
"--no-datalog",\
18+
"--print-active-checkers",\
19+
"--loop-hoisting",\
20+
"--quandary",\
21+
"--racerd",\
22+
"--starvation",\
23+
"--uninit",\
24+
"--disable-issue-type", "BUFFER_OVERRUN_L2",\
25+
"--disable-issue-type", "PULSE_UNNECESSARY_COPY",\
26+
"--enable-issue-type", "EXPENSIVE_EXECUTION_TIME",\
27+
"--enable-issue-type", "INVARIANT_CALL",\
28+
"--enable-issue-type", "PULSE_UNINITIALIZED_CONST",\
29+
"--enable-issue-type", "SENSITIVE_DATA_FLOW",\
30+
"--enable-issue-type", "UNTRUSTED_BUFFER_ACCESS",\
31+
"--enable-issue-type", "UNTRUSTED_HEAP_ALLOCATION",\
32+
"--disable-issue-type", "USE_AFTER_FREE_LATENT",\
33+
"--disable-issue-type", "STACK_VARIABLE_ADDRESS_ESCAPE",\
34+
"--disable-issue-type", "INVARIANT_CALL",\
35+
"--fail-on-issue"]
36+
# In the above, the first 2 are disabled for extreme sensitivity and false
37+
# positives, the ones at the end are probably decent, but have some false
38+
# positives, so we can't fail-on-issue with them on.
39+
# INVARIANT_CALL is pretty fun, but currently wrong, because it can't see
40+
# through potential mutations via callbacks. Our code is bad and we should
41+
# feel bad, but until that's fixed, the invariant checker doesn't work.

other/docker/infer/run

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/sh
2+
3+
set -eux
4+
BUILD=infer
5+
docker build -t "toxchat/c-toxcore:$BUILD" -f "other/docker/$BUILD/Dockerfile" .

toxav/ring_buffer.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ uint16_t rb_size(const RingBuffer *b)
106106
uint16_t rb_data(const RingBuffer *b, void **dest)
107107
{
108108
uint16_t i;
109+
const uint16_t size = rb_size(b);
109110

110-
for (i = 0; i < rb_size(b); ++i) {
111+
for (i = 0; i < size; ++i) {
111112
dest[i] = b->data[(b->start + i) % b->size];
112113
}
113114

toxcore/TCP_connection.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,9 @@ static TCP_con *get_tcp_connection(const TCP_Connections *tcp_c, int tcp_connect
290290
uint32_t tcp_connected_relays_count(const TCP_Connections *tcp_c)
291291
{
292292
uint32_t count = 0;
293+
const uint32_t size = tcp_connections_count(tcp_c);
293294

294-
for (uint32_t i = 0; i < tcp_connections_count(tcp_c); ++i) {
295+
for (uint32_t i = 0; i < size; ++i) {
295296
const TCP_con *tcp_con = get_tcp_connection(tcp_c, i);
296297

297298
if (tcp_con == nullptr) {

toxcore/group_chats.c

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6211,6 +6211,39 @@ static bool handle_gc_lossless_packet(const GC_Session *c, GC_Chat *chat, const
62116211
return true;
62126212
}
62136213

6214+
non_null(1, 2, 3, 4, 6) nullable(8)
6215+
static int handle_gc_lossy_packet_decoded(
6216+
const GC_Session *c, GC_Chat *chat, GC_Connection *gconn, const GC_Peer *peer,
6217+
uint8_t packet_type, const uint8_t *data, uint16_t payload_len, void *userdata)
6218+
{
6219+
switch (packet_type) {
6220+
case GP_MESSAGE_ACK: {
6221+
return handle_gc_message_ack(chat, gconn, data, payload_len);
6222+
}
6223+
6224+
case GP_PING: {
6225+
return handle_gc_ping(chat, gconn, data, payload_len);
6226+
}
6227+
6228+
case GP_INVITE_RESPONSE_REJECT: {
6229+
return handle_gc_invite_response_reject(c, chat, data, payload_len, userdata);
6230+
}
6231+
6232+
case GP_CUSTOM_PACKET: {
6233+
return handle_gc_custom_packet(c, chat, peer, data, payload_len, false, userdata);
6234+
}
6235+
6236+
case GP_CUSTOM_PRIVATE_PACKET: {
6237+
return handle_gc_custom_private_packet(c, chat, peer, data, payload_len, false, userdata);
6238+
}
6239+
6240+
default: {
6241+
LOGGER_WARNING(chat->log, "Warning: handling invalid lossy group packet type 0x%02x", packet_type);
6242+
return -1;
6243+
}
6244+
}
6245+
}
6246+
62146247
/** @brief Handles lossy groupchat message packets.
62156248
*
62166249
* This function assumes the length has already been validated.
@@ -6259,41 +6292,7 @@ static bool handle_gc_lossy_packet(const GC_Session *c, GC_Chat *chat, const uin
62596292
return false;
62606293
}
62616294

6262-
int ret = -1;
6263-
const uint16_t payload_len = (uint16_t)len;
6264-
6265-
switch (packet_type) {
6266-
case GP_MESSAGE_ACK: {
6267-
ret = handle_gc_message_ack(chat, gconn, data, payload_len);
6268-
break;
6269-
}
6270-
6271-
case GP_PING: {
6272-
ret = handle_gc_ping(chat, gconn, data, payload_len);
6273-
break;
6274-
}
6275-
6276-
case GP_INVITE_RESPONSE_REJECT: {
6277-
ret = handle_gc_invite_response_reject(c, chat, data, payload_len, userdata);
6278-
break;
6279-
}
6280-
6281-
case GP_CUSTOM_PACKET: {
6282-
ret = handle_gc_custom_packet(c, chat, peer, data, payload_len, false, userdata);
6283-
break;
6284-
}
6285-
6286-
case GP_CUSTOM_PRIVATE_PACKET: {
6287-
ret = handle_gc_custom_private_packet(c, chat, peer, data, payload_len, false, userdata);
6288-
break;
6289-
}
6290-
6291-
default: {
6292-
LOGGER_WARNING(chat->log, "Warning: handling invalid lossy group packet type 0x%02x", packet_type);
6293-
free(data);
6294-
return false;
6295-
}
6296-
}
6295+
const int ret = handle_gc_lossy_packet_decoded(c, chat, gconn, peer, packet_type, data, (uint16_t)len, userdata);
62976296

62986297
free(data);
62996298

0 commit comments

Comments
 (0)