Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Devel-PPPort CPAN distribution.

Report information
The Basics
Id: 25372
Status: resolved
Priority: 0/
Queue: Devel-PPPort

People
Owner: Nobody in particular
Requestors: salva [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: 3.11_02



Subject: special case sv_magic(sv, obj, how, name, 0)
the function sv_magic... void sv_magic(SV* sv, SV* obj, int how, const char* name, I32 namlen); stores a copy of the string in name inside the magical structure, but from 5.8.0, when namelen is 0, it stores the pointer value instead of a copy. Modules taken advantage of this special case handling, do not work under older perls. I think Devel::PPPort should take care of this API change.
First of all, I'd like to apologize for this reply coming so late. But somehow your message didn't make it into my inbox and I just found it by accident when I logged into RT today. As for sv_magic(), I don't think that this can be easily, if at all, done by Devel::PPPort. There are several problems: 1. The change in behaviour is about *not* doing something, not about doing something extra. This means it cannot be done by wrapping sv_magic() in a macro or something like that, it would have to be done by re-implementing sv_magic() in ppport.h. This is ugly, but certainly doable. 2. The real problem is that by the time sv_unmagic() is called, older perls will always attempt to Safefree() the mg_ptr, whether it's a copy or not. And this behaviour cannot be influenced by Devel::PPPort. So, unless I'm completely wrong [*], this problem cannot be solved by Devel::PPPort. You have to take care in the XS code, or just drop support for pre-5.8 perls. Sorry for the bad news, Marcus [*] In that case, please let me know! :-)
From: SALVA [...] cpan.org
Hi, Show quoted text
> 2. The real problem is that by the time sv_unmagic() is called, > older perls will always attempt to Safefree() the mg_ptr, > whether it's a copy or not. And this behaviour cannot be > influenced by Devel::PPPort. > > So, unless I'm completely wrong [*], this problem cannot be solved > by Devel::PPPort.
It is not very elegant, but I think that setting mg->mg_len = -1 will do: #define my_sv_magic(sv, obj, how, name, namelen) if (!name || namelen != 0) sv_magic(sv, obj, how, name, namelen else { sv_magic(sv, obj, how, 0, 0); mg = ...; mg->mg_len = -1; mg->mg_ptr = name; } Or at least, a warning could be printed: #define my_sv_magic(sv, obj, how, name, namelen) if ((name) && !(namelen)) Perl_warn("..."); sv_magic(sv, obj, how, name, namelen);
I think I fixed this with Devel-PPPort-3.11_02. Feel free to reopen the ticket if it's not working for you. Marcus