all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Po Lu <luangruo@yahoo.com>
To: emacs-devel@gnu.org
Cc: Vibhav Pant <vibhavp@gmail.com>
Subject: Re: feature/asan-gc-poisoning 5c653d3ec9: Add support for additional memory checks using AddressSanitizer.
Date: Wed, 30 Nov 2022 12:58:09 +0800	[thread overview]
Message-ID: <87h6yhujha.fsf@yahoo.com> (raw)
In-Reply-To: <20221129213444.5CC36C009EC@vcs2.savannah.gnu.org> (Vibhav Pant's message of "Tue, 29 Nov 2022 16:34:44 -0500 (EST)")

Vibhav Pant <vibhavp@gmail.com> writes:

>     Add support for additional memory checks using AddressSanitizer.
>     
>     When Emacs is compiled with AddressSanitizer support, enable
>     poisoning/unpoisoning freed/unused Lisp objects and other internal
>     memory management structures. If enabled, this will mark freed bytes
>     that have been put on free lists for future use, and initially
>     allocated memory blocks/chunks as "poisoned", triggering an ASan error
>     if they are accessed improperly. Structures are unpoisoned when they
>     have been taken off their respective free lists.
>     
>     * configure.ac: Check for the existence of the ASan API header.
>     
>     * src/alloc.c (ASAN_POISON_ABLOCK, ASAN_UNPOISON_ABLOCK)
>     (ASAN_POISON_INTERVAL_BLOCK, ASAN_UNPOISON_INTERVAL_BLOCK)
>     (ASAN_POISON_INTERVAL, ASAN_UNPOISON_INTERVAL)
>     (ASAN_PREPARE_DEAD_SDATA, ASAN_PREPARE_LIVE_SDATA)
>     (ASAN_POISON_SBLOCK_DATA, ASAN_POISON_STRING_BLOCK)
>     (ASAN_UNPOISON_STRING_BLOCK, ASAN_POISON_STRING)
>     (ASAN_UNPOISON_STRING, ASAN_POISON_FLOAT_BLOCK)
>     (ASAN_UNPOISON_FLOAT_BLOCK, ASAN_POISON_FLOAT)
>     (ASAN_UNPOISON_FLOAT, ASAN_POISON_CONS_BLOCK)
>     (ASAN_POISON_CONS, ASAN_UNPOISON_CONS)
>     (ASAN_POISON_VECTOR_CONTENTS, ASAN_UNPOISON_VECTOR_CONTENTS)
>     (ASAN_UNPOISON_VECTOR_BLOCK, ASAN_POISON_SYMBOL_BLOCK)
>     (ASAN_UNPOISON_SYMBOL_BLOCK, ASAN_POISON_SYMBOL)
>     (ASAN_UNPOISON_SYMBOL) [ADDRESS_SANITIZER]: New functions. When
>     address sanitization is enabled, define them to poison/unpoison
>     objects.
>     
>     (lisp_align_malloc): Poison newly allocated blocks on `free_ablock',
>     unpoison ablocks taken from it respectively.
>     (lisp_align_free): Poison individual ablocks when they are put on the
>     free list, unpoison them when an entire `ablocks' chunk is being
>     freed.
>     
>     (make_interval): Poison interval blocks on initial allocation,
>     unpoison individual intervals on allocation and removal from
>     `interval_free_list'.
>     (sweep_intervals): Unpoison interval blocks before sweeping, poison
>     dead/unmarked intervals.
>     
>     (allocate_string): Poison string blocks on initial allocation,
>     unpoison Lisp_Strings on removal from the free list.
>     (allocate_string_data): Poison `sblock' data on initial allocation,
>     unpoison individual `sdata' contents on allocation or removal from the
>     free list. Call `ASAN_PREPARE_LIVE_SDATA' on the new `sdata' struct.
>     (sweep_strings): Unpoison string blocks before sweeping them,
>     poisoning dead strings and their sdata afterwards.
>     (compact_small_strings): Call `ASAN_PREPARE_LIVE_DATA' on the `sdata'
>     to where compacted strings to moved to.
>     (pin_string): Call `ASAN_PREPARE_DEAD_SDATA' on `old_sdata'.
>     
>     (make_float): Poison float blocks on allocation, unpoisoning
>     individual Lisp_Floats on allocation or removal from
>     `float_free_list'.
>     (sweep_floats): Unpoison float blocks before sweeping, poison
>     dead/unmarked floats.
>     
>     (free_cons): Poison `ptr'.
>     (Fcons): Poison cons blocks on allocation, unpoisoning individual
>     Lisp_Cons on allocation or removal from `cons_free_list'.
>     (sweep_conses): Poison dead/unmarked conses.
>     
>     (setup_free_list): Poison vectors put on `vector_free_lists'.
>     (allocate_vector_from_block): Unpoison vectors taken from the free
>     list, poison excess vector bytes when vectors allocated from the free
>     list are larger than requested.
>     (sweep_vectors): Unpoison vector blocks before sweeping them.
>     
>     (Fmake_symbol): Poison symbol blocks on initial allocation,
>     unpoisoning individual Lisp_Symbols on allocation or removal from
>     `symbol_free_list'.
>     (sweep_symbols): Unpoison symbol blocks before sweeping, poisoning
>     dead/unmarked symbols.

Thank you for writing the change log entry correctly this time!
> +   This feature can be disabled wtih the run-time flag
> +   `allow_user_poisoning' set to zero.
> +*/

Please put "*/" at the end of "zero.".

> +  (void) (b);

> +  (void) (b);

I thought Emacs doesn't make the compiler warn about unused arguments.

> +#if GC_ASAN_POISON_OBJECTS
> +	/* Ensure that accessing excess bytes does not trigger ASan.
> +	 */
> +	__asan_unpoison_memory_region (ADVANCE (vector, nbytes),
> +				       restbytes);
> +#endif

Please fix the comment here as well.

The rest LGTM.  Thanks for paying attention to our coding style this
time.



       reply	other threads:[~2022-11-30  4:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <166975768364.28465.5012752085318372072@vcs2.savannah.gnu.org>
     [not found] ` <20221129213444.5CC36C009EC@vcs2.savannah.gnu.org>
2022-11-30  4:58   ` Po Lu [this message]
2022-11-30 13:41     ` feature/asan-gc-poisoning 5c653d3ec9: Add support for additional memory checks using AddressSanitizer Eli Zaretskii

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h6yhujha.fsf@yahoo.com \
    --to=luangruo@yahoo.com \
    --cc=emacs-devel@gnu.org \
    --cc=vibhavp@gmail.com \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.