[Rcpp-devel] Fwd: Exposed class works within cpp func, bombs via module
Thell Fowler
tbfowler4 at gmail.com
Wed Feb 26 20:48:04 CET 2014
On Wed, Feb 26, 2014 at 12:56 PM, Thell Fowler <tbfowler4 at gmail.com> wrote:
> On Wed, Feb 26, 2014 at 12:33 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
>>
>> On 26 February 2014 at 12:26, Thell Fowler wrote:
>> | BTW - what was the fix/issue you tackled yesterday? Possibly any relation?
>>
>> Unrelated, mostly, as it was a for loop with iterators using comparison
>> (wrongly) and arithmetic on the iterator object. In that case using
>> old-school indices worked more reliably. Somewhat related in the sense that
>> unnecessary complexity was added by trying to be clever via iterators.
>>
>> Here we don't know. It could be something in our backend, or it could be your
>> code.
>>
>> Dirk
>>
>> --
>> Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
>
>
> Good point regarding 'being clever' with the iterators.
>
> Here's a small reproducible sample of without _anything_ else going on...
>
> https://gist.github.com/Thell/9231866
>
> Output::
>
>> # Via Rcpp
>> rcpp_BadIter(1)
> Initializing:
> state.begin addr: 0x1d96b70
> state_iter addr: 0x1d96b70
> Accessing:
> state.begin addr: 0x1d96b70
> state_iter addr: 0x1d96b70
>
>> # Via R
>> bi <- make_BadIter(1)
> Initializing:
> state.begin addr: 0x24225d0
> state_iter addr: 0x24225d0
>
>> bi$access( )
> Accessing:
> state.begin addr: 0x4108c70
> state_iter addr: 0x24225d0
> [1] 0
>
> It looks like it is on the back-end to me...
>
> --
> Sincerely,
> Thell
Narrowed down to invalidation of pointer because data (vec) is moved
_after_ the constructor exits. Setting the iterator member after the
construction has completed looks to resolve the issue.
So, construct, { init, use }...
Is that change of address on purpose to facilitate the Rcpp/R bridge
or is it a side effect?
--
Sincerely,
Thell
More information about the Rcpp-devel
mailing list