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

configure (AC_LBL_UNALIGNED_ACCESS): Avoid implicit function decls #7

Merged
merged 1 commit into from
Oct 2, 2023

Conversation

fweimer-rh
Copy link

Implicit function declarations were removed from the C language in 1999. Include the relevant header files to ensure that the check still works with future compilers. C99 also requires to declare the return types of all functions.

See openargus/argus#5.

Implicit function declarations were removed from the C language
in 1999.  Include the relevant header files to ensure that the
check still works with future compilers.  C99 also requires
to declare the return types of all functions.
@openargus openargus merged commit 4470e16 into openargus:master Oct 2, 2023
openargus pushed a commit that referenced this pull request Mar 7, 2024
Fixes the following potential data race found with Valgrind (helgrind)

==8412== Possible data race during write of size 4 at 0xA5ACA34 by thread #7
==8412== Locks held: 2, at addresses 0xA5ACA40 0x270E180
==8412==    at 0x44722F: ArgusAddToQueue (argus_util.c:18547)
==8412==    by 0x408C15: RaProcessThisRecord (raclient.c:1563)
==8412==    by 0x407BEB: RaProcessRecord (raclient.c:1244)
==8412==    by 0x41F8ED: RaScheduleRecord (argus_util.c:2912)
==8412==    by 0x41FE9F: ArgusHandleRecord (argus_util.c:3028)
==8412==    by 0x47395E: ArgusReadStreamSocket (argus_client.c:451)
==8412==    by 0x474690: ArgusReadStream (argus_client.c:801)
==8412==    by 0x4051A9: ArgusProcessData (raclient.c:332)
==8412==    by 0x6345881: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==8412==    by 0x6D59DC4: start_thread (in /usr/lib64/libpthread-2.17.so)
==8412==    by 0x7B41CEC: clone (in /usr/lib64/libc-2.17.so)
==8412==
==8412== This conflicts with a previous read of size 4 by thread #6
==8412== Locks held: 1, at address 0x704060
==8412==    at 0x40BE12: ArgusOutputProcess (rasqlinsert.c:425)
==8412==    by 0x6345881: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==8412==    by 0x6D59DC4: start_thread (in /usr/lib64/libpthread-2.17.so)
==8412==    by 0x7B41CEC: clone (in /usr/lib64/libc-2.17.so)
==8412==  Address 0xa5aca34 is 4 bytes inside a block of size 80 alloc'd
==8412==    at 0x6342D94: calloc (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==8412==    by 0x454032: ArgusCalloc (argus_util.c:23908)
==8412==    by 0x446EBC: ArgusNewQueue (argus_util.c:18423)
==8412==    by 0x40B3EE: RaCursesNewProcess (raclient.c:2393)
==8412==    by 0x40597E: ArgusClientInit (raclient.c:514)
==8412==    by 0x40B88E: main (rasqlinsert.c:267)
==8412==  Block was alloc'd by thread #1

(cherry picked from commit 5eca6afcf111a761c38aa8e8b715330ae82be89b)

Conflicts:
	examples/ramysql/rasqlinsert.c

Partial cherry-pick: only argus_util missing changes.
openargus pushed a commit that referenced this pull request Mar 7, 2024
Lock queue before deleting contents.  Found with Helgrind:

==3994== Possible data race during read of size 8 at 0xA5B0B28 by thread #6
==3994== Locks held: 2, at addresses 0x705060 0xA5B0B00
==3994==    at 0x40C2B0: ArgusProcessSqlData (rasqlinsert.c:476)
==3994==    by 0x40C148: ArgusOutputProcess (rasqlinsert.c:432)
==3994==    by 0x6346881: ??? (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==3994==    by 0x6D5ADC4: start_thread (in /usr/lib64/libpthread-2.17.so)
==3994==    by 0x7B42CEC: clone (in /usr/lib64/libc-2.17.so)
==3994==
==3994== This conflicts with a previous write of size 8 by thread #7
==3994== Locks held: none
==3994==    at 0x447B07: ArgusPopQueue (argus_util.c:18699)
==3994==    by 0x408204: RaProcessThisRecord (raclient.c:1407)
==3994==    by 0x407B7A: RaProcessRecord (raclient.c:1226)
==3994==    by 0x41FD4D: RaScheduleRecord (argus_util.c:2933)
==3994==    by 0x4202FF: ArgusHandleRecord (argus_util.c:3049)
==3994==    by 0x473EEA: ArgusReadStreamSocket (argus_client.c:451)
==3994==    by 0x474C1C: ArgusReadStream (argus_client.c:801)
==3994==    by 0x405223: ArgusProcessData (raclient.c:345)
==3994==  Address 0xa5b0b28 is 56 bytes inside a block of size 80 alloc'd
==3994==    at 0x6343D94: calloc (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==3994==    by 0x4547AD: ArgusCalloc (argus_util.c:24020)
==3994==    by 0x447637: ArgusNewQueue (argus_util.c:18536)
==3994==    by 0x40B6A2: RaCursesNewProcess (raclient.c:2476)
==3994==    by 0x406CCA: ArgusClientInit (raclient.c:885)
==3994==    by 0x40BB42: main (rasqlinsert.c:268)
==3994==  Block was alloc'd by thread #1
openargus pushed a commit that referenced this pull request Mar 7, 2024
pthread_mutex_destroy() fails if the mutex is locked and, according
to the man page "results in undefined behavior."

Found by Helgrind:

==5143== Thread #7: pthread_mutex_destroy of a locked mutex
==5143==    at 0x6347AAC: pthread_mutex_destroy (in /usr/lib64/valgrind/vgpreload_helgrind-amd64-linux.so)
==5143==    by 0x44774C: ArgusDeleteQueue (argus_util.c:18571)
==5143==    by 0x496CAA: ArgusDeleteAggregator (argus_client.c:11952)
==5143==    by 0x481623: RaDeleteBin (argus_client.c:5283)
==5143==    by 0x47DAC4: ArgusDeleteRecordStruct (argus_client.c:3911)
==5143==    by 0x408241: RaProcessThisRecord (raclient.c:1409)
==5143==    by 0x407B7A: RaProcessRecord (raclient.c:1226)
==5143==    by 0x41FD71: RaScheduleRecord (argus_util.c:2933)
==5143==    by 0x420323: ArgusHandleRecord (argus_util.c:3049)
==5143==    by 0x473F0E: ArgusReadStreamSocket (argus_client.c:451)
==5143==    by 0x474C40: ArgusReadStream (argus_client.c:801)
==5143==    by 0x405223: ArgusProcessData (raclient.c:345)
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

Successfully merging this pull request may close these issues.

None yet

2 participants