-
Notifications
You must be signed in to change notification settings - Fork 28
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
Regression with Perl 5.6.0 in the Compress::Raw::* modules #231
Comments
Hello, it would be nice to provide example how to trigger this bug without external modules, or with just simple C/XS module. This could help me and other people to check if the problem is in ppport, perl or external module. |
I've done some digging. Enclosed module, demo-1.1.tar.gz, is a stripped down example with a test file for each of the two issues I'm seeing. Issue looks very similar in both tests, so I'll only walk through the first one. This is the striped down XS code. All it does take an
Once built, just run With Perl 5.30.2 I get this
The Data buffer and length returned from Now the same test with 5.6
and there is the problem -- the value returned from |
Thanks for the input. Can also paste your perl |
The This is how it is invoked.
|
Thank you for input. I have reproduced this issue. I been looking at it and I think now I know where is the problem and how to fix. Problem is in the SvPV_nomg(), more precisely in Perl_sv_2pv() function which this macro calls. Perl_sv_2pv() function prior to Perl 5.18 has an issue which cause that it returns empty string if it is called scalar which has PV/string value but does not have any other (NV, IV, ...). This problem was fixed in Perl 5.18 in commit 4bac9ae (Magic flags harmonization). My proposed fix is for Perl < 5.18 version to redefine sv_2pv() macro/function to something like this: #if PERL_VERSION < 18
#ifdef sv_2pv
#undef sv_2pv
#endif
#if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN)
#define sv_2pv(sv, lp) ({ SV *_sv_2pv = (sv); SvPOKp(_sv_2pv) ? ((*(lp) = SvCUR(_sv_2pv)), SvPVX(_sv_2pv)) : Perl_sv_2pv(aTHX_ _sv_2pv, (lp)); })
#else
#define sv_2pv(sv, lp) (SvPOKp(sv) ? ((*(lp) = SvCUR(sv)), SvPVX(sv)) : Perl_sv_2pv(aTHX_ (sv), (lp)))
#endif
#endif After redefining, Perl 5.6 SvPV_nomg() macro starts using fixed version. After putting this code into demo.xs after the ppport.h line, I was not able to trigger it anymore. Can you check if it works correctly? If yes then the fix should be integrated into |
That worked fine, both with gcc & clang version of 5.6 Also tried on GitHub for a second opinion. All ok there as well |
Perfect! Would you like to prepare a proper fix for Devel-PPPort (into file parts/inc/SvPV)? |
Thanks, but no. I'll pass on that. |
Ok, pull request is there: #232 I had to slightly modify my above change as it did not compile for Perl versions 5.10+. |
The
Compress::Raw::*
modules have been using version 5.52 ofDevel-PPPort
for years. Lately an issue with clang compiler warnings cropped up so I needed to refresh it.Updating to 3.71 fixed the clang issue, but broke the test harness when I use Perl 5.6. All other Perl versions are fine. Example at https://github.com/pmqs/Compress-Raw-Zlib/actions/runs/5910264156/job/16031671226
I tried a few versions of
Devel-PPPort
but could not get one that fixed both the clang issue and worked with perl 5.6. Think that the 5.6 issue starts with Devel-PPPort 3.57I suspect there is one underlying issue, but there are two distinct failures
Use of substr
Looking at the failing tests a key observation is the use of
substr
as a parameter to one of the zlib methods. Like this, for exampleI remember adding these particular tests years ago because the use of
substr
caused problems in the past.Below will reproduce the failure
this is the output I get
One point - in the real test harness some of the
substr
lines will throw aUse of uninitialized value in subroutine entry
warning. For some reason that isn't happening in the test file. No idea why.non-PV buffer
The second failure is in the test harness file
t/019nonpv.t
These tests pass buffers that are created like this
Not sure if this is a variation on the
substr
issue.I can collect more data if needed.
The text was updated successfully, but these errors were encountered: