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

libc/qsort: fix invalid-pointer-pair if enable detect_invalid_pointer_pairs=2 #9207

Merged
merged 1 commit into from May 8, 2023

Conversation

anchao
Copy link
Contributor

@anchao anchao commented May 8, 2023

Summary

libc/qsort: fix invalid-pointer-pair if enable detect_invalid_pointer_pairs=2

================================================================= ==2920138==ERROR: AddressSanitizer: invalid-pointer-pair: 0x603000000130 0x000000000000
    #0 0x5602d3c6a89d in qsort stdlib/lib_qsort.c:180
    #1 0x5602d3c28928 in romfs_cachenode romfs/fs_romfsutil.c:503
    #2 0x5602d3c2854d in romfs_cachenode romfs/fs_romfsutil.c:486
    #3 0x5602d3c2b056 in romfs_fsconfigure romfs/fs_romfsutil.c:777
    #4 0x5602d3c24856 in romfs_bind romfs/fs_romfs.c:1111
    #5 0x5602d3bf5179 in nx_mount mount/fs_mount.c:427
    #6 0x5602d3bf5796 in mount mount/fs_mount.c:539
    #7 0x5602d3bc1154 in nsh_romfsetc apps/nshlib/nsh_romfsetc.c:110
    #8 0x5602d3b8f38d in nsh_initialize apps/nshlib/nsh_init.c:127
    #9 0x5602d3b8f2b7 in nsh_main apps/system/nsh/nsh_main.c:69
    #10 0x5602d3b7a3a6 in nxtask_startup sched/task_startup.c:70
    #11 0x5602d3b5de89 in nxtask_start task/task_start.c:134

0x603000000130 is located 0 bytes inside of 32-byte region [0x603000000130,0x603000000150) allocated by thread T0 here:
    #0 0x7fcdac74793c in __interceptor_posix_memalign ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:226
    #1 0x5602d3c9024e in host_memalign sim/posix/sim_hostmemory.c:180
    #2 0x5602d3c907d2 in host_realloc sim/posix/sim_hostmemory.c:222
    #3 0x5602d3b8aaff in mm_realloc sim/sim_heap.c:262
    #4 0x5602d3b87a6a in realloc umm_heap/umm_realloc.c:91
    #5 0x5602d3c280c4 in romfs_cachenode romfs/fs_romfsutil.c:466
    #6 0x5602d3c2854d in romfs_cachenode romfs/fs_romfsutil.c:486
    #7 0x5602d3c2b056 in romfs_fsconfigure romfs/fs_romfsutil.c:777
    #8 0x5602d3c24856 in romfs_bind romfs/fs_romfs.c:1111
    #9 0x5602d3bf5179 in nx_mount mount/fs_mount.c:427
    #10 0x5602d3bf5796 in mount mount/fs_mount.c:539
    #11 0x5602d3bc1154 in nsh_romfsetc apps/nshlib/nsh_romfsetc.c:110
    #12 0x5602d3b8f38d in nsh_initialize apps/nshlib/nsh_init.c:127
    #13 0x5602d3b8f2b7 in nsh_main apps/system/nsh/nsh_main.c:69
    #14 0x5602d3b7a3a6 in nxtask_startup sched/task_startup.c:70
    #15 0x5602d3b5de89 in nxtask_start task/task_start.c:134

Address 0x000000000000 is a wild pointer.
SUMMARY: AddressSanitizer: invalid-pointer-pair stdlib/lib_qsort.c:180 in qsort ==2920138==ABORTING
Aborted (core dumped)

Impact

N/A

Testing

asan

…_pairs=2

=================================================================
==2920138==ERROR: AddressSanitizer: invalid-pointer-pair: 0x603000000130 0x000000000000
    #0 0x5602d3c6a89d in qsort stdlib/lib_qsort.c:180
    #1 0x5602d3c28928 in romfs_cachenode romfs/fs_romfsutil.c:503
    #2 0x5602d3c2854d in romfs_cachenode romfs/fs_romfsutil.c:486
    #3 0x5602d3c2b056 in romfs_fsconfigure romfs/fs_romfsutil.c:777
    #4 0x5602d3c24856 in romfs_bind romfs/fs_romfs.c:1111
    #5 0x5602d3bf5179 in nx_mount mount/fs_mount.c:427
    #6 0x5602d3bf5796 in mount mount/fs_mount.c:539
    apache#7 0x5602d3bc1154 in nsh_romfsetc apps/nshlib/nsh_romfsetc.c:110
    apache#8 0x5602d3b8f38d in nsh_initialize apps/nshlib/nsh_init.c:127
    apache#9 0x5602d3b8f2b7 in nsh_main apps/system/nsh/nsh_main.c:69
    apache#10 0x5602d3b7a3a6 in nxtask_startup sched/task_startup.c:70
    apache#11 0x5602d3b5de89 in nxtask_start task/task_start.c:134

0x603000000130 is located 0 bytes inside of 32-byte region [0x603000000130,0x603000000150)
allocated by thread T0 here:
    #0 0x7fcdac74793c in __interceptor_posix_memalign ../../../../src/libsanitizer/asan/asan_malloc_linux.cpp:226
    #1 0x5602d3c9024e in host_memalign sim/posix/sim_hostmemory.c:180
    #2 0x5602d3c907d2 in host_realloc sim/posix/sim_hostmemory.c:222
    #3 0x5602d3b8aaff in mm_realloc sim/sim_heap.c:262
    #4 0x5602d3b87a6a in realloc umm_heap/umm_realloc.c:91
    #5 0x5602d3c280c4 in romfs_cachenode romfs/fs_romfsutil.c:466
    #6 0x5602d3c2854d in romfs_cachenode romfs/fs_romfsutil.c:486
    apache#7 0x5602d3c2b056 in romfs_fsconfigure romfs/fs_romfsutil.c:777
    apache#8 0x5602d3c24856 in romfs_bind romfs/fs_romfs.c:1111
    apache#9 0x5602d3bf5179 in nx_mount mount/fs_mount.c:427
    apache#10 0x5602d3bf5796 in mount mount/fs_mount.c:539
    apache#11 0x5602d3bc1154 in nsh_romfsetc apps/nshlib/nsh_romfsetc.c:110
    apache#12 0x5602d3b8f38d in nsh_initialize apps/nshlib/nsh_init.c:127
    apache#13 0x5602d3b8f2b7 in nsh_main apps/system/nsh/nsh_main.c:69
    apache#14 0x5602d3b7a3a6 in nxtask_startup sched/task_startup.c:70
    apache#15 0x5602d3b5de89 in nxtask_start task/task_start.c:134

Address 0x000000000000 is a wild pointer.
SUMMARY: AddressSanitizer: invalid-pointer-pair stdlib/lib_qsort.c:180 in qsort
==2920138==ABORTING
Aborted (core dumped)

Signed-off-by: chao an <anchao@xiaomi.com>
@jerpelea jerpelea merged commit 3403b98 into apache:master May 8, 2023
26 checks passed
@jerpelea jerpelea added this to To-Add in Release Notes - 12.2.0 Jun 13, 2023
@jerpelea jerpelea moved this from To-Add to In Progress in Release Notes - 12.2.0 Jun 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants