<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">(now with some links):<div><br><div><div>Le 28 mai 2014 à 16:31, John Mous <<a href="mailto:john.mous0@gmail.com">john.mous0@gmail.com</a>> a écrit :</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr">The object really is just built as part of the return statement. i.e. the lines from my prior e-mail exist as-is in the full code,</div></blockquote><div><br></div><div>Sure. What happens is that Rcpp::export generates something that calls wrap( std::map<std::string,int> ). </div><div><br></div><blockquote type="cite"><div dir="ltr"> there's just more that actually builds the variables X1-X4 beforehand. </div></blockquote><div><br></div><div>It should not be relevant. </div><br><blockquote type="cite"><div dir="ltr">So I'm not sure where to debug from the client side. I'm a C/C++ developer, but have no experience with Rcpp internals or the general interface between R and C. I can insert some debug statements on the Rcpp side if you can guide me to where wrap is defined. <br></div></blockquote><div><br></div><div>well wrap is defined here: </div><div><a href="https://github.com/RcppCore/Rcpp/blob/master/inst/include/Rcpp/internal/wrap_end.h#L28">https://github.com/RcppCore/Rcpp/blob/master/inst/include/Rcpp/internal/wrap_end.h#L28</a></div><div><br></div><div>It then performs a series of dispatch, that eventually lead to something that handles std::map<std::string,int>: </div><div><a href="https://github.com/RcppCore/Rcpp/blob/master/inst/include/Rcpp/internal/wrap.h#L255">https://github.com/RcppCore/Rcpp/blob/master/inst/include/Rcpp/internal/wrap.h#L255</a></div><div><br></div><div><pre style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; margin-top: 0px; margin-bottom: 0px; color: rgb(51, 51, 51); line-height: 18px;"><div class="line" id="LC254" style="box-sizing: border-box; padding-left: 10px; height: 18px;"><span class="n" style="box-sizing: border-box;">template</span> <span class="o" style="box-sizing: border-box; font-weight: bold;"><</span><span class="kr" style="box-sizing: border-box; font-weight: bold;">typename</span> <span class="n" style="box-sizing: border-box;">InputIterator</span><span class="p" style="box-sizing: border-box;">,</span> <span class="kr" style="box-sizing: border-box; font-weight: bold;">typename</span> <span class="n" style="box-sizing: border-box;">T</span><span class="o" style="box-sizing: border-box; font-weight: bold;">></span></div><div class="line" id="LC255" style="box-sizing: border-box; padding-left: 10px; height: 18px; background-color: rgb(255, 255, 204);"><span class="kr" style="box-sizing: border-box; font-weight: bold;">inline</span> <span class="n" style="box-sizing: border-box;">SEXP</span> <span class="n" style="box-sizing: border-box;">range_wrap_dispatch___impl__cast</span><span class="p" style="box-sizing: border-box;">(</span> <span class="n" style="box-sizing: border-box;">InputIterator</span> <span class="n" style="box-sizing: border-box;">first</span><span class="p" style="box-sizing: border-box;">,</span> <span class="n" style="box-sizing: border-box;">InputIterator</span> <span class="n" style="box-sizing: border-box;">last</span><span class="p" style="box-sizing: border-box;">,</span> <span class="o" style="box-sizing: border-box; font-weight: bold;">::</span><span class="n" style="box-sizing: border-box;">Rcpp</span><span class="o" style="box-sizing: border-box; font-weight: bold;">::</span><span class="n" style="box-sizing: border-box;">traits</span><span class="o" style="box-sizing: border-box; font-weight: bold;">::</span><span class="n" style="box-sizing: border-box;">false_type</span> <span class="p" style="box-sizing: border-box;">){</span></div><div class="line" id="LC256" style="box-sizing: border-box; padding-left: 10px; height: 18px;">  <span class="kt" style="box-sizing: border-box; color: rgb(68, 85, 136); font-weight: bold;">size_t</span> <span class="n" style="box-sizing: border-box;">size</span> <span class="o" style="box-sizing: border-box; font-weight: bold;">=</span> <span class="n" style="box-sizing: border-box;">std</span><span class="o" style="box-sizing: border-box; font-weight: bold;">::</span><span class="n" style="box-sizing: border-box;">distance</span><span class="p" style="box-sizing: border-box;">(</span> <span class="n" style="box-sizing: border-box;">first</span><span class="p" style="box-sizing: border-box;">,</span> <span class="n" style="box-sizing: border-box;">last</span> <span class="p" style="box-sizing: border-box;">)</span> <span class="p" style="box-sizing: border-box;">;</span></div><div class="line" id="LC257" style="box-sizing: border-box; padding-left: 10px; height: 18px;">      <span class="k" style="box-sizing: border-box; font-weight: bold;">const</span> <span class="kt" style="box-sizing: border-box; color: rgb(68, 85, 136); font-weight: bold;">int</span> <span class="n" style="box-sizing: border-box;">RTYPE</span> <span class="o" style="box-sizing: border-box; font-weight: bold;">=</span> <span class="o" style="box-sizing: border-box; font-weight: bold;">::</span><span class="n" style="box-sizing: border-box;">Rcpp</span><span class="o" style="box-sizing: border-box; font-weight: bold;">::</span><span class="n" style="box-sizing: border-box;">traits</span><span class="o" style="box-sizing: border-box; font-weight: bold;">::</span><span class="n" style="box-sizing: border-box;">r_sexptype_traits</span><span class="o" style="box-sizing: border-box; font-weight: bold;"><</span><span class="kr" style="box-sizing: border-box; font-weight: bold;">typename</span> <span class="n" style="box-sizing: border-box;">T</span><span class="o" style="box-sizing: border-box; font-weight: bold;">::</span><span class="n" style="box-sizing: border-box;">second_type</span><span class="o" style="box-sizing: border-box; font-weight: bold;">>::</span><span class="n" style="box-sizing: border-box;">rtype</span> <span class="p" style="box-sizing: border-box;">;</span></div><div class="line" id="LC258" style="box-sizing: border-box; padding-left: 10px; height: 18px;">       <span class="n" style="box-sizing: border-box;">Shield</span><span class="o" style="box-sizing: border-box; font-weight: bold;"><</span><span class="n" style="box-sizing: border-box;">SEXP</span><span class="o" style="box-sizing: border-box; font-weight: bold;">></span> <span class="n" style="box-sizing: border-box;">x</span><span class="p" style="box-sizing: border-box;">(</span> <span class="n" style="box-sizing: border-box;">Rf_allocVector</span><span class="p" style="box-sizing: border-box;">(</span> <span class="n" style="box-sizing: border-box;">RTYPE</span><span class="p" style="box-sizing: border-box;">,</span> <span class="n" style="box-sizing: border-box;">size</span> <span class="p" style="box-sizing: border-box;">)</span> <span class="p" style="box-sizing: border-box;">);</span></div><div class="line" id="LC259" style="box-sizing: border-box; padding-left: 10px; height: 18px;">  <span class="n" style="box-sizing: border-box;">Shield</span><span class="o" style="box-sizing: border-box; font-weight: bold;"><</span><span class="n" style="box-sizing: border-box;">SEXP</span><span class="o" style="box-sizing: border-box; font-weight: bold;">></span> <span class="n" style="box-sizing: border-box;">names</span><span class="p" style="box-sizing: border-box;">(</span> <span class="n" style="box-sizing: border-box;">Rf_allocVector</span><span class="p" style="box-sizing: border-box;">(</span> <span class="n" style="box-sizing: border-box;">STRSXP</span><span class="p" style="box-sizing: border-box;">,</span> <span class="n" style="box-sizing: border-box;">size</span> <span class="p" style="box-sizing: border-box;">)</span> <span class="p" style="box-sizing: border-box;">)</span> <span class="p" style="box-sizing: border-box;">;</span></div><div class="line" id="LC260" style="box-sizing: border-box; padding-left: 10px; height: 18px;">     <span class="k" style="box-sizing: border-box; font-weight: bold;">typedef</span> <span class="kr" style="box-sizing: border-box; font-weight: bold;">typename</span> <span class="o" style="box-sizing: border-box; font-weight: bold;">::</span><span class="n" style="box-sizing: border-box;">Rcpp</span><span class="o" style="box-sizing: border-box; font-weight: bold;">::</span><span class="n" style="box-sizing: border-box;">traits</span><span class="o" style="box-sizing: border-box; font-weight: bold;">::</span><span class="n" style="box-sizing: border-box;">storage_type</span><span class="o" style="box-sizing: border-box; font-weight: bold;"><</span><span class="n" style="box-sizing: border-box;">RTYPE</span><span class="o" style="box-sizing: border-box; font-weight: bold;">>::</span><span class="n" style="box-sizing: border-box;">type</span> <span class="n" style="box-sizing: border-box;">CTYPE</span> <span class="p" style="box-sizing: border-box;">;</span></div><div class="line" id="LC261" style="box-sizing: border-box; padding-left: 10px; height: 18px;"> <span class="n" style="box-sizing: border-box;">CTYPE</span><span class="o" style="box-sizing: border-box; font-weight: bold;">*</span> <span class="n" style="box-sizing: border-box;">start</span> <span class="o" style="box-sizing: border-box; font-weight: bold;">=</span> <span class="n" style="box-sizing: border-box;">r_vector_start</span><span class="o" style="box-sizing: border-box; font-weight: bold;"><</span><span class="n" style="box-sizing: border-box;">RTYPE</span><span class="o" style="box-sizing: border-box; font-weight: bold;">></span><span class="p" style="box-sizing: border-box;">(</span><span class="n" style="box-sizing: border-box;">x</span><span class="p" style="box-sizing: border-box;">)</span> <span class="p" style="box-sizing: border-box;">;</span></div><div class="line" id="LC262" style="box-sizing: border-box; padding-left: 10px; height: 18px;">  <span class="kt" style="box-sizing: border-box; color: rgb(68, 85, 136); font-weight: bold;">size_t</span> <span class="n" style="box-sizing: border-box;">i</span> <span class="o" style="box-sizing: border-box; font-weight: bold;">=</span><span class="mi" style="box-sizing: border-box; color: rgb(0, 153, 153);">0</span><span class="p" style="box-sizing: border-box;">;</span></div><div class="line" id="LC263" style="box-sizing: border-box; padding-left: 10px; height: 18px;">        <span class="n" style="box-sizing: border-box;">std</span><span class="o" style="box-sizing: border-box; font-weight: bold;">::</span><span class="n" style="box-sizing: border-box;">string</span> <span class="n" style="box-sizing: border-box;">buf</span> <span class="p" style="box-sizing: border-box;">;</span></div><div class="line" id="LC264" style="box-sizing: border-box; padding-left: 10px; height: 18px;">  <span class="k" style="box-sizing: border-box; font-weight: bold;">for</span><span class="p" style="box-sizing: border-box;">(</span> <span class="p" style="box-sizing: border-box;">;</span> <span class="n" style="box-sizing: border-box;">i</span><span class="o" style="box-sizing: border-box; font-weight: bold;"><</span><span class="n" style="box-sizing: border-box;">size</span><span class="p" style="box-sizing: border-box;">;</span> <span class="n" style="box-sizing: border-box;">i</span><span class="o" style="box-sizing: border-box; font-weight: bold;">++</span><span class="p" style="box-sizing: border-box;">,</span> <span class="o" style="box-sizing: border-box; font-weight: bold;">++</span><span class="n" style="box-sizing: border-box;">first</span><span class="p" style="box-sizing: border-box;">){</span></div><div class="line" id="LC265" style="box-sizing: border-box; padding-left: 10px; height: 18px;">          <span class="n" style="box-sizing: border-box;">start</span><span class="p" style="box-sizing: border-box;">[</span><span class="n" style="box-sizing: border-box;">i</span><span class="p" style="box-sizing: border-box;">]</span> <span class="o" style="box-sizing: border-box; font-weight: bold;">=</span> <span class="p" style="box-sizing: border-box;">(</span><span class="o" style="box-sizing: border-box; font-weight: bold;">*</span><span class="n" style="box-sizing: border-box;">first</span><span class="p" style="box-sizing: border-box;">).</span><span class="n" style="box-sizing: border-box;">second</span> <span class="p" style="box-sizing: border-box;">;</span></div><div class="line" id="LC266" style="box-sizing: border-box; padding-left: 10px; height: 18px;">          <span class="n" style="box-sizing: border-box;">buf</span> <span class="o" style="box-sizing: border-box; font-weight: bold;">=</span> <span class="p" style="box-sizing: border-box;">(</span><span class="o" style="box-sizing: border-box; font-weight: bold;">*</span><span class="n" style="box-sizing: border-box;">first</span><span class="p" style="box-sizing: border-box;">).</span><span class="n" style="box-sizing: border-box;">first</span> <span class="p" style="box-sizing: border-box;">;</span></div><div class="line" id="LC267" style="box-sizing: border-box; padding-left: 10px; height: 18px;">             <span class="n" style="box-sizing: border-box;">SET_STRING_ELT</span><span class="p" style="box-sizing: border-box;">(</span> <span class="n" style="box-sizing: border-box;">names</span><span class="p" style="box-sizing: border-box;">,</span> <span class="n" style="box-sizing: border-box;">i</span><span class="p" style="box-sizing: border-box;">,</span> <span class="n" style="box-sizing: border-box;">Rf_mkChar</span><span class="p" style="box-sizing: border-box;">(</span><span class="n" style="box-sizing: border-box;">buf</span><span class="p" style="box-sizing: border-box;">.</span><span class="n" style="box-sizing: border-box;">c_str</span><span class="p" style="box-sizing: border-box;">())</span> <span class="p" style="box-sizing: border-box;">)</span> <span class="p" style="box-sizing: border-box;">;</span></div><div class="line" id="LC268" style="box-sizing: border-box; padding-left: 10px; height: 18px;">   <span class="p" style="box-sizing: border-box;">}</span></div><div class="line" id="LC269" style="box-sizing: border-box; padding-left: 10px; height: 18px;"> <span class="o" style="box-sizing: border-box; font-weight: bold;">::</span><span class="n" style="box-sizing: border-box;">Rf_setAttrib</span><span class="p" style="box-sizing: border-box;">(</span> <span class="n" style="box-sizing: border-box;">x</span><span class="p" style="box-sizing: border-box;">,</span> <span class="n" style="box-sizing: border-box;">R_NamesSymbol</span><span class="p" style="box-sizing: border-box;">,</span> <span class="n" style="box-sizing: border-box;">names</span> <span class="p" style="box-sizing: border-box;">)</span> <span class="p" style="box-sizing: border-box;">;</span></div><div class="line" id="LC270" style="box-sizing: border-box; padding-left: 10px; height: 18px;">     <span class="k" style="box-sizing: border-box; font-weight: bold;">return</span> <span class="n" style="box-sizing: border-box;">wrap_extra_steps</span><span class="o" style="box-sizing: border-box; font-weight: bold;"><</span><span class="n" style="box-sizing: border-box;">T</span><span class="o" style="box-sizing: border-box; font-weight: bold;">></span><span class="p" style="box-sizing: border-box;">(</span> <span class="n" style="box-sizing: border-box;">x</span> <span class="p" style="box-sizing: border-box;">)</span> <span class="p" style="box-sizing: border-box;">;</span></div><div class="line" id="LC271" style="box-sizing: border-box; padding-left: 10px; height: 18px;"><span class="p" style="box-sizing: border-box;">}</span></div></pre><div><br></div><div>what I suspect to be the problem is this line:</div><div><br></div><div> <span class="o" style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; line-height: 18px; white-space: pre; box-sizing: border-box; font-weight: bold;">::</span><span class="n" style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; line-height: 18px; white-space: pre; box-sizing: border-box;">Rf_setAttrib</span><span class="p" style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; line-height: 18px; white-space: pre; box-sizing: border-box;">(</span><span style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; line-height: 18px; white-space: pre;"> </span><span class="n" style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; line-height: 18px; white-space: pre; box-sizing: border-box;">x</span><span class="p" style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; line-height: 18px; white-space: pre; box-sizing: border-box;">,</span><span style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; line-height: 18px; white-space: pre;"> </span><span class="n" style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; line-height: 18px; white-space: pre; box-sizing: border-box;">R_NamesSymbol</span><span class="p" style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; line-height: 18px; white-space: pre; box-sizing: border-box;">,</span><span style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; line-height: 18px; white-space: pre;"> </span><span class="n" style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; line-height: 18px; white-space: pre; box-sizing: border-box;">names</span><span style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; line-height: 18px; white-space: pre;"> </span><span class="p" style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; line-height: 18px; white-space: pre; box-sizing: border-box;">)</span><span style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; line-height: 18px; white-space: pre;"> </span><span class="p" style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Courier, monospace; font-size: 12px; line-height: 18px; white-space: pre; box-sizing: border-box;">;</span></div></div><div><br></div><div><br></div><blockquote type="cite"><div dir="ltr">What Romain says makes sense to me, despite my lack of expertise in this area.. the really intermittent nature of the problem and the fact that I can't recreate it in a small / fast running example suggests that perhaps this manifests when R happens to garbage collect at an unfortunate time (if I understood correctly). Thanks again.</div></blockquote><div><br></div><div>Something like that. as hadley hinted, please try this under gc torture, or preferably through a debugger. </div><br><blockquote type="cite"><div class="gmail_extra"><div class="gmail_quote">On Wed, May 28, 2014 at 10:12 AM, Dirk Eddelbuettel <span dir="ltr"><<a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class=""><br>
On 28 May 2014 at 10:02, John Mous wrote:<br>
| Hmm, unfortunately the GitHub version failed also.<br>
<br>
</div>Darn.<br>
<div class=""><br>
| The attributes on the failed<br>
| object are a little different though, here's what they look like:<br>
|<br>
| Browse[1]> str(results)<br>
|  atomic [1:4] 1 1 2270 0<br>
|  - attr(*, "")= symbol sim<br>
|  - attr(*, "value")= promise to  NULL<br>
<br>
</div>I am not sure what we can do without a reproducible example. :-/<br>
The code just got a review / refreshment over the last few months.<br>
<br>
You best bet may the slow and tedious insertion of debug statements to see<br>
when / if the object changes.<br>
<span class="HOEnZb"><font color="#888888"><br>
Dirk<br>
<br>
--<br>
Dirk Eddelbuettel | <a href="mailto:edd@debian.org">edd@debian.org</a> | <a href="http://dirk.eddelbuettel.com/" target="_blank">http://dirk.eddelbuettel.com</a><br>
</font></span></blockquote></div><br></div>
_______________________________________________<br>Rcpp-devel mailing list<br><a href="mailto:Rcpp-devel@lists.r-forge.r-project.org">Rcpp-devel@lists.r-forge.r-project.org</a><br>https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</blockquote></div><br></div></body></html>