develooper Front page | perl.perl5.porters | Postings from December 2013

[perl #120826] call_sv's docs are misleading

Thread Next
From:
bulk88
Date:
December 19, 2013 09:47
Subject:
[perl #120826] call_sv's docs are misleading
Message ID:
rt-4.0.18-13437-1387446437-1607.120826-75-0@perl.org
# New Ticket Created by  bulk88 
# Please include the string:  [perl #120826]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=120826 >


This is a bug report for perl from bulk88@hotmail.com,
generated with the help of perlbug 1.39 running under perl 5.19.7.


-----------------------------------------------------------------
[Please describe your issue here]

call_sv's docs currently say

---------------------------------------------------------------
=for apidoc p||call_sv

Performs a callback to the Perl sub whose name is in the SV.  See
L<perlcall>.

=cut
---------------------------------------------------------------

That says it is exactly equivalent to "call_pv(SvPV_nolen(sv),0);"

perlcall says "This allows you to specify the Perl subroutine to be 
called either as a C string (which has first been converted to an SV) or 
a reference to a subroutine."

So my question is, what is the all inclusive list of what call_sv can be 
used on? And more specifically, will call_sv take a CV *? Not a SV * ref 
to a CV *, but a CV *?

I put a warn on SvTYPE into XS-APITest,

------------------------------------------------------
    Creating library ..\..\lib\auto\XS\APItest\APItest.lib and object 
..\..\lib\a
uto\XS\APItest\APItest.exp
Generating code
Finished generating code
         if exist ..\..\lib\auto\XS\APItest\APItest.dll.manifest mt 
-nologo -mani
fest ..\..\lib\auto\XS\APItest\APItest.dll.manifest 
-outputresource:..\..\lib\au
to\XS\APItest\APItest.dll;2
         if exist ..\..\lib\auto\XS\APItest\APItest.dll.manifest del 
..\..\lib\au
to\XS\APItest\APItest.dll.manifest
         C:\p519\src\miniperl.exe "-I..\..\lib" "-I..\..\lib" 
-MExtUtils::Command
  -e chmod -- 755 ..\..\lib\auto\XS\APItest\APItest.dll
         ..\..\perl.exe "-I..\..\lib" "-I..\..\lib" 
"-MExtUtils::Command::MM" "-M
Test::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 
'..\..\lib'
, '..\..\lib')" t/*.t
t/addissub.t ................. ok
t/arrayexpr.t ................ ok
t/autoload.t ................. ok
t/blockasexpr.t .............. ok
t/blockhooks-csc.t ........... ok
t/blockhooks.t ............... ok
t/call.t ..................... type of SV is 1
type of SV is 9
type of SV is 3
# Failed test 10 - 0 args, G_VOID G_EVAL call_sv('d') - warning at 
t/call.t line
  97
#      got "type of SV is 3\n"
# expected ""
# Failed test 22 - 0 args, G_VOID G_KEEPERR G_EVAL call_sv('d') - 
warning at t/c
all.t line 97
#      got "type of SV is 3\n\t(in cleanup) its_dead_jim\n"
# expected "\t(in cleanup) its_dead_jim\n"
type of SV is 3
type of SV is 3
type of SV is 1
type of SV is 9
type of SV is 3
# Failed test 47 - 3 args, G_VOID G_EVAL call_sv('d') - warning at 
t/call.t line
  97
#      got "type of SV is 3\n"
# expected ""
# Failed test 59 - 3 args, G_VOID G_KEEPERR G_EVAL call_sv('d') - 
warning at t/c
all.t line 97
#      got "type of SV is 3\n\t(in cleanup) its_dead_jim\n"
# expected "\t(in cleanup) its_dead_jim\n"
type of SV is 3
type of SV is 3
type of SV is 1
type of SV is 9
type of SV is 3
# Failed test 84 - 0 args, G_SCALAR G_EVAL call_sv('d') - warning at 
t/call.t li
ne 97
#      got "type of SV is 3\n"
# expected ""
# Failed test 96 - 0 args, G_SCALAR G_KEEPERR G_EVAL call_sv('d') - 
warning at t
/call.t line 97
#      got "type of SV is 3\n\t(in cleanup) its_dead_jim\n"
# expected "\t(in cleanup) its_dead_jim\n"
type of SV is 3
type of SV is 3
type of SV is 1
type of SV is 9
type of SV is 3
# Failed test 121 - 3 args, G_SCALAR G_EVAL call_sv('d') - warning at 
t/call.t l
ine 97
#      got "type of SV is 3\n"
# expected ""
# Failed test 133 - 3 args, G_SCALAR G_KEEPERR G_EVAL call_sv('d') - 
warning at
t/call.t line 97
#      got "type of SV is 3\n\t(in cleanup) its_dead_jim\n"
# expected "\t(in cleanup) its_dead_jim\n"
type of SV is 3
type of SV is 3
type of SV is 1
type of SV is 9
type of SV is 3
# Failed test 158 - 0 args, G_ARRAY G_EVAL call_sv('d') - warning at 
t/call.t li
ne 97
#      got "type of SV is 3\n"
# expected ""
# Failed test 170 - 0 args, G_ARRAY G_KEEPERR G_EVAL call_sv('d') - 
warning at t
/call.t line 97
t/call.t ..................... 1/436 #      got "type of SV is 3\n\t(in 
cleanup)
  its_dead_jim\n"
# expected "\t(in cleanup) its_dead_jim\n"
type of SV is 3
type of SV is 3
type of SV is 1
type of SV is 9
type of SV is 3
# Failed test 195 - 3 args, G_ARRAY G_EVAL call_sv('d') - warning at 
t/call.t li
ne 97
#      got "type of SV is 3\n"
# expected ""
# Failed test 207 - 3 args, G_ARRAY G_KEEPERR G_EVAL call_sv('d') - 
warning at t
/call.t line 97
#      got "type of SV is 3\n\t(in cleanup) its_dead_jim\n"
# expected "\t(in cleanup) its_dead_jim\n"
type of SV is 3
type of SV is 3
type of SV is 1
type of SV is 9
type of SV is 3
# Failed test 232 - 0 args, G_DISCARD G_EVAL call_sv('d') - warning at 
t/call.t
line 97
#      got "type of SV is 3\n"
# expected ""
# Failed test 244 - 0 args, G_DISCARD G_KEEPERR G_EVAL call_sv('d') - 
warning at
  t/call.t line 97
#      got "type of SV is 3\n\t(in cleanup) its_dead_jim\n"
# expected "\t(in cleanup) its_dead_jim\n"
type of SV is 3
type of SV is 3
type of SV is 1
type of SV is 9
type of SV is 3
# Failed test 269 - 3 args, G_DISCARD G_EVAL call_sv('d') - warning at 
t/call.t
line 97
#      got "type of SV is 3\n"
# expected ""
# Failed test 281 - 3 args, G_DISCARD G_KEEPERR G_EVAL call_sv('d') - 
warning at
  t/call.t line 97
#      got "type of SV is 3\n\t(in cleanup) its_dead_jim\n"
# expected "\t(in cleanup) its_dead_jim\n"
type of SV is 3
type of SV is 3
# Failed test 300 - at t/call.t line 170
#      got "type of SV is 1\n"
# expected ""
# Failed test 302 - at t/call.t line 176
#      got "type of SV is 1\n"
# expected ""
# Failed test 304 - at t/call.t line 170
#      got "type of SV is 1\n"
# expected ""
# Failed test 306 - at t/call.t line 176
#      got "type of SV is 1\n"
# expected ""
# Failed test 308 - at t/call.t line 170
#      got "type of SV is 1\n"
# expected ""
# Failed test 310 - at t/call.t line 176
#      got "type of SV is 1\n"
# expected ""
# Failed test 312 - at t/call.t line 170
#      got "type of SV is 1\n"
# expected ""
# Failed test 314 - at t/call.t line 176
#      got "type of SV is 1\n\t(in cleanup) aabbcc\n"
# expected "\t(in cleanup) aabbcc\n"
# Failed test 316 - at t/call.t line 170
#      got "type of SV is 1\n"
# expected ""
# Failed test 318 - at t/call.t line 176
#      got "type of SV is 1\n\t(in cleanup) aabbcc\n"
# expected "\t(in cleanup) aabbcc\n"
# Failed test 320 - at t/call.t line 170
#      got "type of SV is 1\n"
# expected ""
# Failed test 322 - at t/call.t line 176
#      got "type of SV is 1\n\t(in cleanup) aabbcc\n"
# expected "\t(in cleanup) aabbcc\n"
# Failed test 324 - at t/call.t line 170
#      got "type of SV is 1\n"
# expected ""
# Failed test 326 - at t/call.t line 176
#      got "type of SV is 1\n\t(in cleanup) ARRAY(0x1badb2c)"
# expected "\t(in cleanup) ARRAY(0x1badb2c)"
# Failed test 328 - at t/call.t line 170
#      got "type of SV is 1\n"
# expected ""
# Failed test 330 - at t/call.t line 176
#      got "type of SV is 1\n\t(in cleanup) ARRAY(0x1badb2c)"
# expected "\t(in cleanup) ARRAY(0x1badb2c)"
# Failed test 332 - at t/call.t line 170
#      got "type of SV is 1\n"
# expected ""
# Failed test 334 - at t/call.t line 176
#      got "type of SV is 1\n\t(in cleanup) ARRAY(0x1badb2c)"
# expected "\t(in cleanup) ARRAY(0x1badb2c)"
# Failed test 335 - at t/call.t line 185
#      got "type of SV is 1\n"
# expected ""
# Failed test 336 - at t/call.t line 193
#      got "type of SV is 1\n\t(in cleanup) aa\n"
# expected "\t(in cleanup) aa\n"
# Failed test 420 - call_sv('f99', G_EVAL|G_ARRAY|0) - __WARN__ not 
called at t/
call.t line 274
#      got "type of SV is 3\n"
# expected undef
# Failed test 426 - call_sv('f99', G_EVAL|G_ARRAY|G_KEEPERR) - the 
correct error
  message at t/call.t line 277
#      got 'type of SV is 3
# '
# expected /(?^:^$)/
# Failed test 429 - call_sv('d', G_EVAL|G_ARRAY|0) - __WARN__ not called 
at t/ca
ll.t line 274
#      got "type of SV is 3\n"
# expected undef
t/call.t ..................... Failed 39/436 subtests
t/call_checker.t ............. ok
t/caller.t ................... ok
t/callregexec.t .............. ok
t/check_warnings.t ........... ok
t/cleanup.t .................. ok
t/clone-with-stack.t ......... ok
t/cophh.t .................... ok
t/coplabel.t ................. ok
t/copstash.t ................. ok
t/copyhints.t ................ ok
t/customop.t ................. ok
t/eval-filter.t .............. ok
t/exception.t ................ ok
t/fetch_pad_names.t .......... ok
t/gotosub.t .................. ok
t/grok.t ..................... ok
t/gv_autoload4.t ............. ok
t/gv_fetchmeth.t ............. ok
t/gv_fetchmeth_autoload.t .... ok
t/gv_fetchmethod_flags.t ..... ok
t/gv_init.t .................. ok
t/handy.t .................... ok
t/hash.t ..................... ok
t/keyword_multiline.t ........ ok
t/keyword_plugin.t ........... ok
t/labelconst.t ............... ok
t/lexsub.t ................... ok
t/loopblock.t ................ ok
t/looprest.t ................. ok
t/lvalue.t ................... ok
t/magic.t .................... ok
t/magic_chain.t .............. ok
t/mro.t ...................... ok
t/multicall.t ................ ok
t/my_cxt.t ................... ok
t/my_exit.t .................. Can't locate test.pl in @INC (@INC 
contains: C:\p
519\src\lib ..\..\lib C:/p519/src/lib .) at t/my_exit.t line 6.
t/my_exit.t .................. Dubious, test returned 2 (wstat 512, 0x200)
No subtests run
t/newCONSTSUB.t .............. ok
t/op.t ....................... ok
t/op_contextualize.t ......... ok
t/op_list.t .................. ok
t/overload.t ................. ok
t/pad_scalar.t ............... ok
t/peep.t ..................... ok
t/pmflag.t ................... ok
t/postinc.t .................. ok
t/printf.t ................... ok
t/ptr_table.t ................ ok
t/push.t ..................... ok
t/refs.t ..................... ok
t/rmagical.t ................. ok
t/rv2cv_op_cv.t .............. ok
t/savehints.t ................ ok
t/scopelessblock.t ........... ok
t/sort.t ..................... ok
t/stmtasexpr.t ............... ok
t/stmtsasexpr.t .............. ok
t/stuff_modify_bug.t ......... ok
t/stuff_svcur_bug.t .......... ok
t/subcall.t .................. ok
t/sviscow.t .................. ok
t/svpeek.t ................... ok
t/svpv.t ..................... ok
t/svpv_magic.t ............... ok
t/svsetsv.t .................. ok
t/swaplabel.t ................ ok
t/swaptwostmts.t ............. ok
t/sym-hook.t ................. ok
t/temp_lv_sub.t .............. ok
t/underscore_length.t ........ ok
t/utf16_to_utf8.t ............ ok
t/utf8.t ..................... ok
t/whichsig.t ................. ok
t/xs_special_subs.t .......... ok
t/xs_special_subs_require.t .. ok
t/xsub_h.t ................... ok

Test Summary Report
-------------------
t/call.t                   (Wstat: 0 Tests: 436 Failed: 39)
   Failed tests:  10, 22, 47, 59, 84, 96, 121, 133, 158, 170
                 195, 207, 232, 244, 269, 281, 300, 302
                 304, 306, 308, 310, 312, 314, 316, 318
                 320, 322, 324, 326, 328, 330, 332, 334-336
                 420, 426, 429
t/my_exit.t                (Wstat: 512 Tests: 0 Failed: 0)
   Non-zero exit status: 2
   Parse errors: No plan found in TAP output
Files=82, Tests=58285, 51 wallclock secs ( 7.30 usr +  3.64 sys = 10.94 CPU)
Result: FAIL
Failed 2/82 test programs. 39/58285 subtests failed.
NMAKE : fatal error U1077: '..\..\perl.exe' : return code '0xff'
Stop.

C:\p519\src\ext\XS-APItest>
------------------------------------------------------

I got types as far as I can see. 1 (SVt_IV, probably these are refs to 
things), 3 (SVt_PV), and 9 (SVt_PVGV, not sure what this is in Pure 
Perl). NO 13 (SVt_PVCV). The tests are all from a very thin wrapper XSUB 
  around the C call_sv. The sub SV * always comes from @_ in the tests, 
so whether a CV * is allowed is never tested. AFAIK, it is not possible 
to put a CV * on @_ stack from pure perl, is this correct?

The pod needs fixes. I'm still researching whether to add something to 
APITest to test if CV *s can be passed to call_sv.


[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
     category=docs
     severity=low
---
Site configuration information for perl 5.19.7:

Configured by Owner at Thu Nov 28 02:32:44 2013.

Summary of my perl5 (revision 5 version 19 subversion 7) configuration:
   Derived from: 8f47723e28b75530b743941cdd8b07f849ec48e2
   Ancestor: 1061065f7a09399eefb50e9a035502621722bcc0
   Platform:
     osname=MSWin32, osvers=5.1, archname=MSWin32-x86-multi-thread
     uname=''
     config_args='undef'
     hint=recommended, useposix=true, d_sigaction=undef
     useithreads=define, usemultiplicity=define
     useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
     use64bitint=undef, use64bitall=undef, uselongdouble=undef
     usemymalloc=n, bincompat5005=undef
   Compiler:
     cc='cl', ccflags ='-nologo -GF -W3 -O1 -MD -Zi -DNDEBUG -G7 -GL 
-DWIN32 -D_CONSOLE -DNO_STRICT  -DPERL_TEXTMODE_SCRIPTS 
-DPERL_HASH_FUNC_ONE_AT_A_TIME -DPERL_IMPLICIT_CONTEXT 
-DPERL_IMPLICIT_SYS -DUSE_PERLIO -D_USE_32BIT_TIME_T',
     optimize='-O1 -MD -Zi -DNDEBUG -G7 -GL',
     cppflags='-DWIN32'
     ccversion='13.10.6030', gccversion='', gccosandvers=''
     intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
     d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=8
     ivtype='long', ivsize=4, nvtype='double', nvsize=8, 
Off_t='__int64', lseeksize=8
     alignbytes=8, prototype=define
   Linker and Libraries:
     ld='link', ldflags ='-nologo -nodefaultlib -debug -opt:ref,icf 
-ltcg  -libpath:"c:\perl519\lib\CORE"  -machine:x86'
     libpth="C:\Program Files\Microsoft Visual Studio .NET 2003\VC7\lib"
     libs=oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib 
comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib 
netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib  version.lib 
odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib
     perllibs=oldnames.lib kernel32.lib user32.lib gdi32.lib 
winspool.lib  comdlg32.lib advapi32.lib shell32.lib ole32.lib 
oleaut32.lib  netapi32.lib uuid.lib ws2_32.lib mpr.lib winmm.lib 
version.lib odbc32.lib odbccp32.lib comctl32.lib msvcrt.lib
     libc=msvcrt.lib, so=dll, useshrplib=true, libperl=perl519.lib
     gnulibc_version=''
   Dynamic Linking:
     dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
     cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -debug 
-opt:ref,icf -ltcg  -libpath:"c:\perl519\lib\CORE"  -machine:x86'

Locally applied patches:
     uncommitted-changes
     8f47723e28b75530b743941cdd8b07f849ec48e2

---
@INC for perl 5.19.7:
     C:/perl519/site/lib
     C:/perl519/lib
     .

---
Environment for perl 5.19.7:
     HOME (unset)
     LANG (unset)
     LANGUAGE (unset)
     LD_LIBRARY_PATH (unset)
     LOGDIR (unset)
     PATH=C:\perl519\bin;C:\Program Files\Microsoft Visual Studio .NET 
2003\Common7\IDE;C:\Program Files\Microsoft Visual Studio .NET 
2003\VC7\BIN;C:\Program Files\Microsoft Visual Studio .NET 
2003\Common7\Tools;C:\Program Files\Microsoft Visual Studio .NET 
2003\Common7\Tools\bin\prerelease;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\system32\wbem;
     PERL_BADLANG (unset)
     SHELL (unset)


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About