<div dir="ltr">No luck with gctorture on yet, but I haven't run it for very long. It slowed things down to a complete crawl, but maybe in the long run it can recreate the problem faster than running the original code (about 12 hours, the previous estimate of a day was too high), so this may still be worthwhile. <br>
<br>On a whim I did try changing the two instances of Shield to Armor this morning (I was able to locate the code in wrap.h by digging around before I saw your e-mail) and ran the original full code without gctorture on, and the problem still persists. <br>
</div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, May 28, 2014 at 3:44 PM, Romain Francois <span dir="ltr"><<a href="mailto:romain@r-enthusiasts.com" target="_blank">romain@r-enthusiasts.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">(now with some links):<div><br><div><div>Le 28 mai 2014 à 16:31, John Mous <<a href="mailto:john.mous0@gmail.com" target="_blank">john.mous0@gmail.com</a>> a écrit :</div>
<div class=""><br><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><div>Sure. What happens is that Rcpp::export generates something that calls wrap( std::map<std::string,int> ). </div><div class=""><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><div>It should not be relevant. </div><div class=""><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><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" target="_blank">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" target="_blank">https://github.com/RcppCore/Rcpp/blob/master/inst/include/Rcpp/internal/wrap.h#L255</a></div>
<div><br></div><div><pre style="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 style="padding-left:10px;min-height:18px">
<span>template</span> <span style="font-weight:bold"><</span><span style="font-weight:bold">typename</span> <span>InputIterator</span><span>,</span> <span style="font-weight:bold">typename</span> <span>T</span><span style="font-weight:bold">></span></div>
<div style="padding-left:10px;min-height:18px;background-color:rgb(255,255,204)"><span style="font-weight:bold">inline</span> <span>SEXP</span> <span>range_wrap_dispatch___impl__cast</span><span>(</span> <span>InputIterator</span> <span>first</span><span>,</span> <span>InputIterator</span> <span>last</span><span>,</span> <span style="font-weight:bold">::</span><span>Rcpp</span><span style="font-weight:bold">::</span><span>traits</span><span style="font-weight:bold">::</span><span>false_type</span> <span>){</span></div>
<div style="padding-left:10px;min-height:18px"> <span style="color:rgb(68,85,136);font-weight:bold">size_t</span> <span>size</span> <span style="font-weight:bold">=</span> <span>std</span><span style="font-weight:bold">::</span><span>distance</span><span>(</span> <span>first</span><span>,</span> <span>last</span> <span>)</span> <span>;</span></div>
<div style="padding-left:10px;min-height:18px"> <span style="font-weight:bold">const</span> <span style="color:rgb(68,85,136);font-weight:bold">int</span> <span>RTYPE</span> <span style="font-weight:bold">=</span> <span style="font-weight:bold">::</span><span>Rcpp</span><span style="font-weight:bold">::</span><span>traits</span><span style="font-weight:bold">::</span><span>r_sexptype_traits</span><span style="font-weight:bold"><</span><span style="font-weight:bold">typename</span> <span>T</span><span style="font-weight:bold">::</span><span>second_type</span><span style="font-weight:bold">>::</span><span>rtype</span> <span>;</span></div>
<div style="padding-left:10px;min-height:18px"> <span>Shield</span><span style="font-weight:bold"><</span><span>SEXP</span><span style="font-weight:bold">></span> <span>x</span><span>(</span> <span>Rf_allocVector</span><span>(</span> <span>RTYPE</span><span>,</span> <span>size</span> <span>)</span> <span>);</span></div>
<div style="padding-left:10px;min-height:18px"> <span>Shield</span><span style="font-weight:bold"><</span><span>SEXP</span><span style="font-weight:bold">></span> <span>names</span><span>(</span> <span>Rf_allocVector</span><span>(</span> <span>STRSXP</span><span>,</span> <span>size</span> <span>)</span> <span>)</span> <span>;</span></div>
<div style="padding-left:10px;min-height:18px"> <span style="font-weight:bold">typedef</span> <span style="font-weight:bold">typename</span> <span style="font-weight:bold">::</span><span>Rcpp</span><span style="font-weight:bold">::</span><span>traits</span><span style="font-weight:bold">::</span><span>storage_type</span><span style="font-weight:bold"><</span><span>RTYPE</span><span style="font-weight:bold">>::</span><span>type</span> <span>CTYPE</span> <span>;</span></div>
<div style="padding-left:10px;min-height:18px"> <span>CTYPE</span><span style="font-weight:bold">*</span> <span>start</span> <span style="font-weight:bold">=</span> <span>r_vector_start</span><span style="font-weight:bold"><</span><span>RTYPE</span><span style="font-weight:bold">></span><span>(</span><span>x</span><span>)</span> <span>;</span></div>
<div style="padding-left:10px;min-height:18px"> <span style="color:rgb(68,85,136);font-weight:bold">size_t</span> <span>i</span> <span style="font-weight:bold">=</span><span style="color:rgb(0,153,153)">0</span><span>;</span></div>
<div style="padding-left:10px;min-height:18px"> <span>std</span><span style="font-weight:bold">::</span><span>string</span> <span>buf</span> <span>;</span></div><div style="padding-left:10px;min-height:18px">    <span style="font-weight:bold">for</span><span>(</span> <span>;</span> <span>i</span><span style="font-weight:bold"><</span><span>size</span><span>;</span> <span>i</span><span style="font-weight:bold">++</span><span>,</span> <span style="font-weight:bold">++</span><span>first</span><span>){</span></div>
<div style="padding-left:10px;min-height:18px">         <span>start</span><span>[</span><span>i</span><span>]</span> <span style="font-weight:bold">=</span> <span>(</span><span style="font-weight:bold">*</span><span>first</span><span>).</span><span>second</span> <span>;</span></div>
<div style="padding-left:10px;min-height:18px">         <span>buf</span> <span style="font-weight:bold">=</span> <span>(</span><span style="font-weight:bold">*</span><span>first</span><span>).</span><span>first</span> <span>;</span></div>
<div style="padding-left:10px;min-height:18px">         <span>SET_STRING_ELT</span><span>(</span> <span>names</span><span>,</span> <span>i</span><span>,</span> <span>Rf_mkChar</span><span>(</span><span>buf</span><span>.</span><span>c_str</span><span>())</span> <span>)</span> <span>;</span></div>
<div style="padding-left:10px;min-height:18px"> <span>}</span></div><div style="padding-left:10px;min-height:18px">   <span style="font-weight:bold">::</span><span>Rf_setAttrib</span><span>(</span> <span>x</span><span>,</span> <span>R_NamesSymbol</span><span>,</span> <span>names</span> <span>)</span> <span>;</span></div>
<div style="padding-left:10px;min-height:18px"> <span style="font-weight:bold">return</span> <span>wrap_extra_steps</span><span style="font-weight:bold"><</span><span>T</span><span style="font-weight:bold">></span><span>(</span> <span>x</span> <span>)</span> <span>;</span></div>
<div style="padding-left:10px;min-height:18px"><span>}</span></div></pre><div><br></div><div>what I suspect to be the problem is this line:</div><div><br></div><div> <span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;line-height:18px;white-space:pre-wrap;font-weight:bold">::</span><span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;line-height:18px;white-space:pre-wrap">Rf_setAttrib</span><span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;line-height:18px;white-space:pre-wrap">(</span><span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;line-height:18px;white-space:pre-wrap"> </span><span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;line-height:18px;white-space:pre-wrap">x</span><span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;line-height:18px;white-space:pre-wrap">,</span><span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;line-height:18px;white-space:pre-wrap"> </span><span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;line-height:18px;white-space:pre-wrap">R_NamesSymbol</span><span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;line-height:18px;white-space:pre-wrap">,</span><span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;line-height:18px;white-space:pre-wrap"> </span><span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;line-height:18px;white-space:pre-wrap">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-wrap"> </span><span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;line-height:18px;white-space:pre-wrap">)</span><span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;line-height:18px;white-space:pre-wrap"> </span><span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Courier,monospace;font-size:12px;line-height:18px;white-space:pre-wrap">;</span></div>
</div><div class=""><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><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=""><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><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><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><font color="#888888"><br>
Dirk<br>
<br>
--<br>
Dirk Eddelbuettel | <a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a> | <a href="http://dirk.eddelbuettel.com/" target="_blank">http://dirk.eddelbuettel.com</a><br>
</font></span></blockquote></div><br></div></div><div class="">
_______________________________________________<br>Rcpp-devel mailing list<br><a href="mailto:Rcpp-devel@lists.r-forge.r-project.org" target="_blank">Rcpp-devel@lists.r-forge.r-project.org</a><br><a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a></div>
</blockquote></div><br></div></div></blockquote></div><br></div>