[PATCH] Fix alignment bug in Safe-Linking
Eyal Itkin
eyal.itkin@gmail.com
Tue Mar 31 06:13:33 GMT 2020
Attached now is the 2nd patch that only handles the bugfix for 32 bit
binaries, and should go on top of the 1st patch for the indentation
and CR fixes from you and Andreas.
Passes all tests on my 32 bit environment and 64 bit environment.
Best Regards,
Eyal.
On Mon, Mar 30, 2020 at 11:57 PM Carlos O'Donell <carlos@redhat.com> wrote:
>
> On 3/30/20 3:20 PM, Eyal Itkin wrote:
> > OK, will do.
> >
> > I'm still not sure about how exactly I should fix the indentations. It
> > looks like tabs equal 8 spaces, and no more than 7 spaces should be used in
> > a single row. I did understand how spacing for braces and curly braces
> > should work. In addition, I guess that when I split up long string to
> > multiple lines I some how broken the indentations.
> >
> > I read the style guide but couldn't come up with anything on top of what I
> > listed above. Is there something I'm missing? You listed at least one case
> > that I should fix in which I simply can't see what's wrong.
> Sorry, the hard part is that you can't just run indent on the whole file and
> have it DTRT. This code is quite old, and we should fix that for you and future
> developers submitting patches.
>
> The best you can do is copy the entire #if USE_TCACHE block into a distinct C
> file, the one from _int_free (line 4209-4245), stick a "if (1)" at the top to
> keep the nested scope correctly indented, and then run indent on that.
>
> You end up with this:
>
> --- indent-orig.c 2020-03-30 16:52:07.698673512 -0400
> +++ indent.c 2020-03-30 16:52:16.832397293 -0400
> @@ -16,16 +16,17 @@
> tcache_entry *tmp;
> LIBC_PROBE (memory_tcache_double_free, 2, e, tc_idx);
> for (tmp = tcache->entries[tc_idx];
> - tmp;
> - tmp = REVEAL_PTR (tmp->next))
> - {
>
> ^^^ This line only has spaces, but needs a tab and several space.
>
> - if (__glibc_unlikely (!aligned_OK (tmp)))
> - malloc_printerr ("free(): unaligned chunk detected in tcache 2");
> - if (tmp == e)
> - malloc_printerr ("free(): double free detected in tcache 2");
> - /* If we get here, it was a coincidence. We've wasted a
> - few cycles, but don't abort. */
>
> ^^^ These need re-indenting given the new scope you added.
>
> - }
>
> ^^^ Likewise similar with the first curly brace.
>
> + tmp; tmp = REVEAL_PTR (tmp->next))
> + {
> + if (__glibc_unlikely (!aligned_OK (tmp)))
> + malloc_printerr
> + ("free(): unaligned chunk detected in tcache 2");
> + if (tmp == e)
> + malloc_printerr
> + ("free(): double free detected in tcache 2");
> + /* If we get here, it was a coincidence. We've wasted a
> + few cycles, but don't abort. */
> + }
>
> ^^^ All fixed.
>
> }
>
> if (tcache->counts[tc_idx] < mp_.tcache_count)
> ---
>
> This is really esoteric.
>
> Say the word and I'll fix this for you and you can focus on the 32-bit fix? :-)
>
> --
> Cheers,
> Carlos.
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Fix-alignment-bug-in-Safe-Linking.patch
Type: application/octet-stream
Size: 3880 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20200331/3b75570c/attachment-0001.obj>
More information about the Libc-alpha
mailing list