<div dir="ltr">Hi Serguei,<div><br></div><div>Thank you! This didn't directly solve my problem, but it got me looking in the right direction. I ended up connecting to a docker container through VS Code on my host machine (Windows). I didn't wire up the debugger UI (which is really convenient in VS Code) but was able to identify the issue through the VS Code interface which is a lot easier to use than a bare terminal.</div><div><br></div><div>For the record the issue was a call to <b>fclose(pOutStream)</b> where pOutStream was Null. On Windows and MacOS this didn't seem to cause a problem, but in Ubuntu it failed. Sadly the traceback information was not precise enough to identify the offending line of code, so I had to find it iteratively.</div><div><br></div><div>-John</div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Thu, Feb 13, 2025 at 4:23 PM Serguei Sokol <<a href="mailto:serguei.sokol@gmail.com">serguei.sokol@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi John,<br>
<br>
Le 13/02/2025 à 15:17, John Clarke a écrit :<br>
> Hey folks,<br>
> <br>
> I've been developing an Rcpp package on my Mac and testing on Mac and <br>
> Windows. I also have been testing on linux-latest with the standard <br>
> Github action which runs the CMD check. These passed without any problem <br>
> until I implemented a test suite (testthat) and increased the test <br>
> coverage to include additional calls. It turns out that the two main <br>
> functions (and maybe others) that I wrote cause a segfault on Ubuntu <br>
> builds. Several versions on Linux are tested and all fail.<br>
> <br>
> It appears to be related to Rcpp so I'm wondering if you've encountered <br>
> this before and how I might go about finding a solution. I can reproduce <br>
> the error on a local docker image consistently, but... I don't have the <br>
> debugging tools I"m used to on MacOS via VS Code to help me step through <br>
> when the error occurs. And I suspect it has to do with a mismatched <br>
> library version because the tests pass fine on Windows and MacOS. So not <br>
> sure if debugging would help much.<br>
> <br>
> Is there a known configuration/compiling issue/fix that I could try? <br>
You can see some techniques e.g. here <br>
<a href="https://github.com/wch/r-debug/blob/master/debugging-r.md" rel="noreferrer" target="_blank">https://github.com/wch/r-debug/blob/master/debugging-r.md</a><br>
In short, if you already have a docker image, you can compile you code <br>
there with "-g -O0" options and run it in:<br>
<br>
R -d gdb<br>
(gdb) run<br>
<run your R/Rcpp (test)code. An error will bring you back to gdb where <br>
you can check relevant frames, parameters, cals and so on.><br>
<br>
Hoping it helps,<br>
Best,<br>
Serguei.<br>
<br>
<br>
> Apart from installing a full fledged instance of Ubuntu with VS Code and <br>
> debugger, is there a way I can get closer to finding out what the issue is?<br>
> <br>
> Clip from the failed R error messages when I call <br>
> shg$runSimFromFixedValues(N, 0, 0, 1940):<br>
> <br>
> *** caught segfault ***<br>
> address (nil), cause 'memory not mapped'<br>
> <br>
> Traceback:<br>
> 1: .External(list(name = "CppMethod__invoke_notvoid", address = <br>
> <pointer: 0x55efab6ef710>, dll = list(name = "Rcpp", path = "/usr/ <br>
> local/lib/R/site-library/Rcpp/libs/Rcpp.so", dynamicLookup = <br>
> TRUE, handle = <pointer: 0x55efa9b64b30>, info = <pointer: <br>
> 0x55efaa89aaa0>, forceSymbols = FALSE), numParameters = -1L), <br>
> <pointer: 0x55efae9ae1f0>, <pointer: 0x55efaf2399d0>, .pointer, ...)<br>
> 2: shg$runSimFromFixedValues(N, 0, 0, 1940)<br>
> <br>
> Thanks,<br>
> <br>
> -John<br>
> <br>
> John Clarke | Senior Technical Advisor |<br>
> Cornerstone Systems Northwest | <a href="mailto:john.clarke@cornerstonenw.com" target="_blank">john.clarke@cornerstonenw.com</a> <br>
> <mailto:<a href="mailto:john.clarke@cornerstonenw.com" target="_blank">john.clarke@cornerstonenw.com</a>><br>
> <br>
> _______________________________________________<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" rel="noreferrer" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a><br>
<br>
_______________________________________________<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" rel="noreferrer" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/rcpp-devel</a><br>
</blockquote></div>