From: "Paweł Krawczyk" <pawel.krawczyk@hush.com>
To: bug-gnulib@gnu.org
Subject: gl_array_list.c:452:29: runtime error: applying zero offset to null pointer
Date: Thu, 21 Oct 2021 19:38:36 +0000 [thread overview]
Message-ID: <20211021193836.299618017A0@smtp.hushmail.com> (raw)
Hello, I'm running an application using gl_array_list under clang ASAN and getting the following complaints:
gl_array_list.c:452:29: runtime error: applying zero offset to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior gl_array_list.c:452:29 in
gl_array_list.c:453:29: runtime error: applying zero offset to null pointer
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior gl_array_list.c:453:29 in
Linest 452-453 are gl_array_list.c:
result.p = list->elements + 0;
result.q = list->elements + list->count;
And indeed, when inspected I found out that the list passed to the iterator was empty. A simple check using
gl_list_size() prior to calling the iterator solved the problem in my program but maybe that should be also
implemented inside the iterator.
The broader context:
static gl_list_iterator_t _GL_ATTRIBUTE_PURE
gl_array_iterator (gl_list_t list)
{
gl_list_iterator_t result;
result.vtable = list->base.vtable;
result.list = list;
result.count = list->count;
result.p = list->elements + 0;
result.q = list->elements + list->count;
#if defined GCC_LINT || defined lint
result.i = 0;
result.j = 0;
#endif
return result;
}
The command used to compile along with ASAN options:
libtool: compile: clang -DHAVE_CONFIG_H -I. -I.. -g -O2 -fstack-protector-all -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -O0 -ggdb -fstack-protector-all -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fsanitize=address -fsanitize=undefined -fsanitize=leak -fsanitize-address-use-after-scope -fcf-protection=full -MT gl_array_list.lo -MD -MP -MF .deps/gl_array_list.Tpo -c gl_array_list.c -fPIC -DPIC -o .libs/gl_array_list.o
--
Pawel Krawczyk
pawel.krawczyk@hush.com +44 7879 180015
CISSP, OWASP, MBCS, CESG SIRA
next reply other threads:[~2021-10-21 20:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-21 19:38 Paweł Krawczyk [this message]
2021-11-01 19:21 ` gl_array_list.c:452:29: runtime error: applying zero offset to null pointer Paul Eggert
2021-11-02 0:46 ` Jeffrey Walton
2021-11-02 1:13 ` Paul Eggert
2022-02-26 19:57 ` Paul Eggert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211021193836.299618017A0@smtp.hushmail.com \
--to=pawel.krawczyk@hush.com \
--cc=bug-gnulib@gnu.org \
--cc=p+hushmail@krvtz.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).