Message ID | 20240903211402.2266742-1-siddhesh@sourceware.org |
---|---|
State | New |
Headers | show |
Series | libio: Attempt wide backup free only for non-legacy code | expand |
* Siddhesh Poyarekar: > _wide_data and _mode are not available in legacy code, so do not attempt > to free the wide backup buffer in legacy code. > > Resolves: BZ #32137 and BZ #27821 > > Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org> > --- > > Tested on x86_64 and i686 for any further regressions, and on i686 by > running libio/tst-stderr-compat under valgrind. > > I could not think of a straightforward test case for the testsuite since > the crash due to freeing _wide_data->_IO_save_base depends on data after > _IO_FILE. I'm relying on, instead this problem to be caught in testing > on old architectures, like it was with BZ #32137. Maybe we also need, > e.g. a ppc32 trybot for pre-commit CI. > > libio/genops.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/libio/genops.c b/libio/genops.c > index 35d8b30710..6f20d49669 100644 > --- a/libio/genops.c > +++ b/libio/genops.c > @@ -819,7 +819,7 @@ _IO_unbuffer_all (void) > /* Free up the backup area if it was ever allocated. */ > if (_IO_have_backup (fp)) > _IO_free_backup_area (fp); > - if (fp->_mode > 0 && _IO_have_wbackup (fp)) > + if (!legacy && fp->_mode > 0 && _IO_have_wbackup (fp)) > _IO_free_wbackup_area (fp); > > if (! (fp->_flags & _IO_UNBUFFERED) This looks correct as far as it goes. GCC could reorder the legacy check and the fp->_mode load, but the existing code already has this problem. I think we should commit this and have Jeevitha P. report back if it fixes powerpc (32-bit). Reviewed-by: Florian Weimer <fweimer@redhat.com> Thanks, Florian
diff --git a/libio/genops.c b/libio/genops.c index 35d8b30710..6f20d49669 100644 --- a/libio/genops.c +++ b/libio/genops.c @@ -819,7 +819,7 @@ _IO_unbuffer_all (void) /* Free up the backup area if it was ever allocated. */ if (_IO_have_backup (fp)) _IO_free_backup_area (fp); - if (fp->_mode > 0 && _IO_have_wbackup (fp)) + if (!legacy && fp->_mode > 0 && _IO_have_wbackup (fp)) _IO_free_wbackup_area (fp); if (! (fp->_flags & _IO_UNBUFFERED)
_wide_data and _mode are not available in legacy code, so do not attempt to free the wide backup buffer in legacy code. Resolves: BZ #32137 and BZ #27821 Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org> --- Tested on x86_64 and i686 for any further regressions, and on i686 by running libio/tst-stderr-compat under valgrind. I could not think of a straightforward test case for the testsuite since the crash due to freeing _wide_data->_IO_save_base depends on data after _IO_FILE. I'm relying on, instead this problem to be caught in testing on old architectures, like it was with BZ #32137. Maybe we also need, e.g. a ppc32 trybot for pre-commit CI. libio/genops.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)