forked from apache/nuttx
-
Notifications
You must be signed in to change notification settings - Fork 0
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
assert: change the do-while of assert to a conditional expression #6
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
According to the standard definition, assert should return a void expression https://pubs.opengroup.org/onlinepubs/007904875/basedefs/assert.h.html This patch involves two changes: If you define the NDEBUG macro, assert does not use any parameters and directly returns a void expression. assert should return a void expression and cannot use do-while statements. If the following code , a compilation error will occur. Signed-off-by: yinshengkai <[email protected]>
The implementation of assert in linux is as follows: After defining NDEBUG in sqlite, some variables will be undefined, and referencing variables in assert will cause compilation errors. sqlite3.c:28729:23: error: ‘mutexIsInit’ undeclared (first use in this function) 28729 | assert( GLOBAL(int, mutexIsInit) ); Signed-off-by: yinshengkai <[email protected]>
Gary-Hobson
pushed a commit
that referenced
this pull request
Oct 8, 2024
ap> cat pm ================================================================= ==30235==ERROR: AddressSanitizer: heap-buffer-overflow on address 0xf436edd9 at pc 0x03338a48 bp 0x9d1b6ca8 sp 0x9d1b6c98 READ of size 1 at 0xf436edd9 thread T0 #0 0x3338a47 in strncmp string/lib_strncmp.c:42 #1 0x371af87 in pm_get_file_index power/pm/pm_procfs.c:174 #2 0x371b066 in pm_open power/pm/pm_procfs.c:207 #3 0x3640d20 in procfs_open procfs/fs_procfs.c:419 #4 0x359bce2 in file_vopen vfs/fs_open.c:240 #5 0x359c431 in nx_vopen vfs/fs_open.c:312 #6 0x359cb53 in open vfs/fs_open.c:465 apache#7 0x33bccc9 in nsh_catfile /apps/nshlib/nsh_fsutils.c:140 apache#8 0x33b28cc in cmd_cat /apps/nshlib/nsh_fscmds.c:556 apache#9 0x33a434f in nsh_command /apps/nshlib/nsh_command.c:1164 apache#10 0x3381b8f in nsh_execute /apps/nshlib/nsh_parse.c:845 apache#11 0x338dc17 in nsh_parse_command /apps/nshlib/nsh_parse.c:2744 apache#12 0x338e273 in nsh_parse /apps/nshlib/nsh_parse.c:2828 apache#13 0x3390b47 in nsh_session /apps/nshlib/nsh_session.c:245 apache#14 0x337e90a in nsh_consolemain /apps/nshlib/nsh_consolemain.c:75 apache#15 0x337e7f7 in nsh_main /apps/system/nsh/nsh_main.c:74 apache#16 0x332b6e6 in nxtask_startup sched/task_startup.c:70 apache#17 0x323ec3f in nxtask_start task/task_start.c:134 apache#18 0x33636ea in pre_start sim/sim_initialstate.c:52 ap> cat net ================================================================= ==30303==ERROR: AddressSanitizer: heap-buffer-overflow on address 0xf4479a5a at pc 0x03338a48 bp 0x9d2b6ce8 sp 0x9d2b6cd8 READ of size 1 at 0xf4479a5a thread T0 #0 0x3338a47 in strncmp string/lib_strncmp.c:42 #1 0x5395d62 in netprocfs_open procfs/net_procfs.c:215 #2 0x3640d20 in procfs_open procfs/fs_procfs.c:419 #3 0x359bce2 in file_vopen vfs/fs_open.c:240 #4 0x359c431 in nx_vopen vfs/fs_open.c:312 #5 0x359cb53 in open vfs/fs_open.c:465 #6 0x33bccc9 in nsh_catfile /apps/nshlib/nsh_fsutils.c:140 apache#7 0x33b28cc in cmd_cat /apps/nshlib/nsh_fscmds.c:556 apache#8 0x33a434f in nsh_command /apps/nshlib/nsh_command.c:1164 apache#9 0x3381b8f in nsh_execute /apps/nshlib/nsh_parse.c:845 apache#10 0x338dc17 in nsh_parse_command /apps/nshlib/nsh_parse.c:2744 apache#11 0x338e273 in nsh_parse /apps/nshlib/nsh_parse.c:2828 apache#12 0x3390b47 in nsh_session /apps/nshlib/nsh_session.c:245 apache#13 0x337e90a in nsh_consolemain /apps/nshlib/nsh_consolemain.c:75 apache#14 0x337e7f7 in nsh_main /apps/system/nsh/nsh_main.c:74 apache#15 0x332b6e6 in nxtask_startup sched/task_startup.c:70 apache#16 0x323ec3f in nxtask_start task/task_start.c:134 apache#17 0x33636ea in pre_start sim/sim_initialstate.c:52 Signed-off-by: dulibo1 <[email protected]> Signed-off-by: buxiasen <[email protected]>
Gary-Hobson
pushed a commit
that referenced
this pull request
Oct 11, 2024
note/note_driver.c:1405:11: runtime error: null pointer passed as argument 2, which is declared to never be null #0 0x33bf5cc in sched_note_event_ip note/note_driver.c:1405 #1 0x33bfb57 in note_driver_instrument_enter note/note_initialize.c:55 #2 0x347b084 in __cyg_profile_func_enter misc/lib_instrument.c:68 #3 0x34179de in binder_initialize binder/binder.c:669 #4 0x339a936 in drivers_initialize /home/cuiziwei/vela/happy/nuttx/drivers/drivers_initialize.c:242 #5 0x335a179 in nx_start init/nx_start.c:632 #6 0x32f755c in main sim/sim_head.c:180 apache#7 0xf6821518 (/lib/i386-linux-gnu/libc.so.6+0x21518) (BuildId: 7f64b917aaa97b9680d8e44931bf7611c5a1f036) apache#8 0xf68215f2 in __libc_start_main (/lib/i386-linux-gnu/libc.so.6+0x215f2) (BuildId: 7f64b917aaa97b9680d8e44931bf7611c5a1f036) apache#9 0x32b401a in _start (/home/cuiziwei/vela/happy/nuttx/nuttx+0x32b401a) (BuildId: 33f8f7b361d44a008de87fea1bc970b22b48b700) Signed-off-by: cuiziwei <[email protected]>
Gary-Hobson
pushed a commit
that referenced
this pull request
Oct 11, 2024
set CONFIG_PRIORITY_INHERITANCE=y set CONFIG_SEM_PREALLOCHOLDERS=0 semaphore/sem_holder.c:320:34: runtime error: member access within null pointer of type 'struct tcb_s' #0 0xd8b540 in nxsem_boostholderprio semaphore/sem_holder.c:320 #1 0xd8c1cf in nxsem_boost_priority semaphore/sem_holder.c:703 #2 0xda5dfa in nxsem_wait semaphore/sem_wait.c:145 #3 0xda61d9 in nxsem_wait_uninterruptible semaphore/sem_wait.c:248 #4 0x12f2477 in media_service_thread0 /home/ligd/platform/dev/apps/examples/hello/hello_main.c:44 #5 0x1204154 in pthread_startup pthread/pthread_create.c:59 #6 0x1cd906f in pthread_start pthread/pthread_create.c:139 apache#7 0xe72fcb in pre_start sim/sim_initialstate.c:52 Signed-off-by: ligd <[email protected]>
Gary-Hobson
pushed a commit
that referenced
this pull request
Oct 11, 2024
note/note_driver.c:1405:11: runtime error: null pointer passed as argument 2, which is declared to never be null #0 0x33bf5cc in sched_note_event_ip note/note_driver.c:1405 #1 0x33bfb57 in note_driver_instrument_enter note/note_initialize.c:55 #2 0x347b084 in __cyg_profile_func_enter misc/lib_instrument.c:68 #3 0x34179de in binder_initialize binder/binder.c:669 #4 0x339a936 in drivers_initialize /home/cuiziwei/vela/happy/nuttx/drivers/drivers_initialize.c:242 #5 0x335a179 in nx_start init/nx_start.c:632 #6 0x32f755c in main sim/sim_head.c:180 apache#7 0xf6821518 (/lib/i386-linux-gnu/libc.so.6+0x21518) (BuildId: 7f64b917aaa97b9680d8e44931bf7611c5a1f036) apache#8 0xf68215f2 in __libc_start_main (/lib/i386-linux-gnu/libc.so.6+0x215f2) (BuildId: 7f64b917aaa97b9680d8e44931bf7611c5a1f036) apache#9 0x32b401a in _start (/home/cuiziwei/vela/happy/nuttx/nuttx+0x32b401a) (BuildId: 33f8f7b361d44a008de87fea1bc970b22b48b700) Signed-off-by: cuiziwei <[email protected]>
Gary-Hobson
pushed a commit
that referenced
this pull request
Oct 12, 2024
note/note_driver.c:1405:11: runtime error: null pointer passed as argument 2, which is declared to never be null #0 0x33bf5cc in sched_note_event_ip note/note_driver.c:1405 #1 0x33bfb57 in note_driver_instrument_enter note/note_initialize.c:55 #2 0x347b084 in __cyg_profile_func_enter misc/lib_instrument.c:68 #3 0x34179de in binder_initialize binder/binder.c:669 #4 0x339a936 in drivers_initialize /home/cuiziwei/vela/happy/nuttx/drivers/drivers_initialize.c:242 #5 0x335a179 in nx_start init/nx_start.c:632 #6 0x32f755c in main sim/sim_head.c:180 apache#7 0xf6821518 (/lib/i386-linux-gnu/libc.so.6+0x21518) (BuildId: 7f64b917aaa97b9680d8e44931bf7611c5a1f036) apache#8 0xf68215f2 in __libc_start_main (/lib/i386-linux-gnu/libc.so.6+0x215f2) (BuildId: 7f64b917aaa97b9680d8e44931bf7611c5a1f036) apache#9 0x32b401a in _start (/home/cuiziwei/vela/happy/nuttx/nuttx+0x32b401a) (BuildId: 33f8f7b361d44a008de87fea1bc970b22b48b700) Signed-off-by: cuiziwei <[email protected]>
Gary-Hobson
pushed a commit
that referenced
this pull request
Oct 12, 2024
note/note_driver.c:1405:11: runtime error: null pointer passed as argument 2, which is declared to never be null #0 0x33bf5cc in sched_note_event_ip note/note_driver.c:1405 #1 0x33bfb57 in note_driver_instrument_enter note/note_initialize.c:55 #2 0x347b084 in __cyg_profile_func_enter misc/lib_instrument.c:68 #3 0x34179de in binder_initialize binder/binder.c:669 #4 0x339a936 in drivers_initialize /home/cuiziwei/vela/happy/nuttx/drivers/drivers_initialize.c:242 #5 0x335a179 in nx_start init/nx_start.c:632 #6 0x32f755c in main sim/sim_head.c:180 apache#7 0xf6821518 (/lib/i386-linux-gnu/libc.so.6+0x21518) (BuildId: 7f64b917aaa97b9680d8e44931bf7611c5a1f036) apache#8 0xf68215f2 in __libc_start_main (/lib/i386-linux-gnu/libc.so.6+0x215f2) (BuildId: 7f64b917aaa97b9680d8e44931bf7611c5a1f036) apache#9 0x32b401a in _start (/home/cuiziwei/vela/happy/nuttx/nuttx+0x32b401a) (BuildId: 33f8f7b361d44a008de87fea1bc970b22b48b700) Signed-off-by: cuiziwei <[email protected]>
Gary-Hobson
pushed a commit
that referenced
this pull request
Oct 12, 2024
note/note_driver.c:1405:11: runtime error: null pointer passed as argument 2, which is declared to never be null #0 0x33bf5cc in sched_note_event_ip note/note_driver.c:1405 #1 0x33bfb57 in note_driver_instrument_enter note/note_initialize.c:55 #2 0x347b084 in __cyg_profile_func_enter misc/lib_instrument.c:68 #3 0x34179de in binder_initialize binder/binder.c:669 #4 0x339a936 in drivers_initialize /home/cuiziwei/vela/happy/nuttx/drivers/drivers_initialize.c:242 #5 0x335a179 in nx_start init/nx_start.c:632 #6 0x32f755c in main sim/sim_head.c:180 apache#7 0xf6821518 (/lib/i386-linux-gnu/libc.so.6+0x21518) (BuildId: 7f64b917aaa97b9680d8e44931bf7611c5a1f036) apache#8 0xf68215f2 in __libc_start_main (/lib/i386-linux-gnu/libc.so.6+0x215f2) (BuildId: 7f64b917aaa97b9680d8e44931bf7611c5a1f036) apache#9 0x32b401a in _start (/home/cuiziwei/vela/happy/nuttx/nuttx+0x32b401a) (BuildId: 33f8f7b361d44a008de87fea1bc970b22b48b700) Signed-off-by: cuiziwei <[email protected]>
Gary-Hobson
pushed a commit
that referenced
this pull request
Oct 14, 2024
note/note_driver.c:1405:11: runtime error: null pointer passed as argument 2, which is declared to never be null #0 0x33bf5cc in sched_note_event_ip note/note_driver.c:1405 #1 0x33bfb57 in note_driver_instrument_enter note/note_initialize.c:55 #2 0x347b084 in __cyg_profile_func_enter misc/lib_instrument.c:68 #3 0x34179de in binder_initialize binder/binder.c:669 #4 0x339a936 in drivers_initialize /home/cuiziwei/vela/happy/nuttx/drivers/drivers_initialize.c:242 #5 0x335a179 in nx_start init/nx_start.c:632 #6 0x32f755c in main sim/sim_head.c:180 apache#7 0xf6821518 (/lib/i386-linux-gnu/libc.so.6+0x21518) (BuildId: 7f64b917aaa97b9680d8e44931bf7611c5a1f036) apache#8 0xf68215f2 in __libc_start_main (/lib/i386-linux-gnu/libc.so.6+0x215f2) (BuildId: 7f64b917aaa97b9680d8e44931bf7611c5a1f036) apache#9 0x32b401a in _start (/home/cuiziwei/vela/happy/nuttx/nuttx+0x32b401a) (BuildId: 33f8f7b361d44a008de87fea1bc970b22b48b700) Signed-off-by: cuiziwei <[email protected]>
Gary-Hobson
pushed a commit
that referenced
this pull request
Oct 16, 2024
stdio/lib_libvsprintf.c:1018:17: runtime error: negation of -9223372036854775808 cannot be represented in type 'long long int'; cast to an unsigned type to negate this value to itself #0 0x3326a86 in vsprintf_internal stdio/lib_libvsprintf.c:1018 #1 0x332926b in lib_vsprintf stdio/lib_libvsprintf.c:1363 #2 0x3777978 in vfprintf stdio/lib_vfprintf.c:52 #3 0x671b3a0 in printf stdio/lib_printf.c:44 #4 0x37abc0c in hello_main /data/project/code/vela-pt/apps/examples/hello/hello_main.c:38 #5 0x33201d3 in nxtask_startup sched/task_startup.c:70 #6 0x3208ecb in nxtask_start task/task_start.c:134 apache#7 0x3357a49 in pre_start sim/sim_initialstate.c:52 Signed-off-by: Bowen Wang <[email protected]>
Gary-Hobson
pushed a commit
that referenced
this pull request
Oct 16, 2024
sim/posix/sim_offload.c:369:18: runtime error: left shift of 255 by 24 places cannot be represented in type 'int' #0 0x3a146c2 (/home/qiaohj/disk1/work/vela/nuttx/nuttx+0x3a146c2) #1 0x3a0ecb0 (/home/qiaohj/disk1/work/vela/nuttx/nuttx+0x3a0ecb0) #2 0x3a1193a (/home/qiaohj/disk1/work/vela/nuttx/nuttx+0x3a1193a) #3 0x3a13141 (/home/qiaohj/disk1/work/vela/nuttx/nuttx+0x3a13141) #4 0x39fc3ef (/home/qiaohj/disk1/work/vela/nuttx/nuttx+0x39fc3ef) #5 0x38ca7f2 (/home/qiaohj/disk1/work/vela/nuttx/nuttx+0x38ca7f2) #6 0x39fc6cf (/home/qiaohj/disk1/work/vela/nuttx/nuttx+0x39fc6cf) Signed-off-by: qiaohaijiao1 <[email protected]>
Gary-Hobson
pushed a commit
that referenced
this pull request
Oct 22, 2024
string/lib_strcpy.c:87:15: runtime error: signed integer overflow: -2132367969 - 16843009 cannot be represented in type 'long int' #0 0x48e77096 in strcpy string/lib_strcpy.c:87 #1 0x535b6ea4 in libconfig_strbuf_append_string libconfig/lib/strbuf.c:60 #2 0x53ad7f52 in libconfig_yyparse /home/ygc/ssd/x4b-sim/external/libconfig/grammar.y:186 #3 0x5358d281 in __config_read libconfig/lib/libconfig.c:561 #4 0x5358dea0 in config_read_file libconfig/lib/libconfig.c:677 #5 0x52cdd0a5 in tts_vendor_list_get src/vendor.c:114 #6 0x52cde739 in default_tts_vendor_get src/vendor.c:356 apache#7 0x52a07e1d in vendorswitch_init src/vendorswitch/vendorswitch.c:501 apache#8 0x52444fb9 in mico_misc_main /home/ygc/ssd/x4b-sim/vendor/xiaomi/miai/mico_misc/instance/main.c:72 apache#9 0x48bee720 in nxtask_startup sched/task_startup.c:70 apache#10 0x48b41eb4 in nxtask_start task/task_start.c:112 apache#11 0x48c1ef3d in pre_start sim/sim_initialstate.c:52 Signed-off-by: yangguangcai <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
assert: change the do-while of assert to a conditional expression
According to the standard definition, assert should return a void expression
https://pubs.opengroup.org/onlinepubs/007904875/basedefs/assert.h.html
This patch involves two changes:
If you define the NDEBUG macro, assert does not use any parameters and directly returns a void expression.
assert should return a void expression and cannot use do-while statements.
If the following code , a compilation error will occur.
Impact
Testing
sim