summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorIlya Zakharevich <ilya@math.ohio-state.edu>1997-01-08 03:25:47 -0500
committerChip Salzenberg <chip@atlantic.net>1997-01-16 07:24:00 +1200
commit7c5b83de28ae2ebfce6a3a7e907a300596342a30 (patch)
tree5f4eea324a072d0392d1968b79d588dfc06ff179 /lib
parentac1ad7f00e63b0423f397847dd05653ab9cea16c (diff)
downloadperl-7c5b83de28ae2ebfce6a3a7e907a300596342a30.tar.gz
Re: xsubpp and Tk ==> segfault
Ilya Zakharevich writes: > > I recall that the reason why void code may be marked as XSRETURN(1) is > that XS TUTORIAL recommended to mark XSUB as void if you manually put It is not perlxstut, it is perlxs. > in stack manipulation! I do not know why this horrible practice is > blessed, but we need a workaround which would allow this mess, and > would not make an XSUB [Add: ] ... segfault if some Perl code was called in between. As I found out, the only difference between an XSUB with a CODE: section which is declared `void' and one which is declared "SV *" is that the first one does not contain a line: SV * RETVAL; Is there any trouble if such a line is present? If nobody will strongly object to it, I will remove an advice to mark a CODE:-XSUBs as `void' from the POD(s). I can also add a warning to xsubpp if a `void' XSUB sets ST(*). What about it? (Warning will be issued only once per .xs .) > Solution: Make the check for CODE section stricter: check for actuall > occurence of "ST(" (with embedded spaces) before making the decision > to XSRETURN(1). The following patch is checked with Perl 3_17 and Tk (it checks for ST at the LHS as an assignment): Enjoy, p5p-msgid: <199701080825.DAA15813@monk.mps.ohio-state.edu>
Diffstat (limited to 'lib')
-rwxr-xr-xlib/ExtUtils/xsubpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/ExtUtils/xsubpp b/lib/ExtUtils/xsubpp
index d43eb1cb23..76e45d6d99 100755
--- a/lib/ExtUtils/xsubpp
+++ b/lib/ExtUtils/xsubpp
@@ -842,6 +842,7 @@ while (fetch_para()) {
$PPCODE = grep(/^\s*PPCODE\s*:/, @line);
$CODE = grep(/^\s*CODE\s*:/, @line);
+ $EXPLICIT_RETURN = $CODE && ("@line" =~ /\bST\s*\([^;]*=/ );
$ALIAS = grep(/^\s*ALIAS\s*:/, @line);
# print function header
@@ -1025,7 +1026,7 @@ EOF
# croak(errbuf);
EOF
- if ($ret_type ne "void" or $CODE) {
+ if ($ret_type ne "void" or $EXPLICIT_RETURN) {
print Q<<EOF unless $PPCODE;
# XSRETURN(1);
EOF