Note that there are some explanatory texts on larger screens.

plurals
  1. POCrash on checking ERRSV when embedding Perl in C++ (Win32)
    primarykey
    data
    text
    <p>I am embedding the Perl interpreter (v 5.16.3) in my Visual C++ based code (on Windows 7). The intention is to invoke a user-written subroutine in Perl from my C++ program. </p> <p>The overall structure of the C++ code to invoke Perl can be thought of as follows:</p> <pre><code>perl_alloc() perl_construct() perl_parse() dSP int result = call_argv(funcName, G_ARRAY|G_EVAL|G_KEEPERR, params); if (SvTRUE (ERRSV)) // &lt;-- crashes here { : } </code></pre> <p>This code crashes at runtime on the marked line. The problem stems from accessing ERRSV, which would be a macro. Doing some troubleshooting, I found out that the troublemaker is the following attribute:</p> <pre><code>vTHX-&gt;Ierrgv </code></pre> <p>i.e., <code>Ierrgv</code> is NULL in my case.</p> <p>If I comment out this error checking (i.e., <code>SvTRUE</code>), the code itself works fine, and I know that my Perl script gets executed as well. I can even retrieve the return parameters from the called subroutine!</p> <p>Can someone tell me <strong>why <code>Ierrgv</code> would be NULL, and what exactly that means?</strong></p> <p>EDIT:</p> <p>Making a small change apparently fixes the problem but without detailed insight into <code>Ierrgv</code> usage, I am not cofident to consider it as a solution:</p> <pre><code>int result = call_argv(funcName, G_ARRAY|G_EVAL|G_KEEPERR, params); if ( (result==0) &amp;&amp; (SvTRUE (ERRSV) ) // &lt;-- doesn't crash here { : } </code></pre> <p>The added check on <code>result</code> ensures that we evaluate <code>ERRSV</code> only when <code>result</code> is zero. As I said earlier, apparently this fixes the problem.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload