• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • About
  • Life
  • Tech
  • Travel
  • Work
  • Questions
  • Contact

Welcome

.

Unbelievable crash R session in R C++ interface

April 11, 2020 by

Questions › Unbelievable crash R session in R C++ interface
0
Vote Up
Vote Down
Garmaine asked 4 years ago

During an implementation of cpp library for R, I'm encountered a strange crash of R session.

I compiled and tested the library in ubuntu with gcc compiler and the function in object works well. Then I compiled the same code in mac OS catalina with clang and the problem arise: R session crash during the function execution.

After some debugger I discovered that the function still works if a factory object inside it is removed. Moreover the crash happens when the C++ routine ends. Note that the library is compiled with c++ 11.

I report a sketch of my code:

# in R scrips:
my_R_function <- function(par1, par2){
   Output_CPP <- my_function(par1, par2)
return output_CPP}

SEXP my_function(SEXP Rpar1, Rpar2){
    double my_par1 = conversion(Rpar1);
    double my_par2 = conversion(Rpar2);

    std::unique_ptr<solver_calss<T>> my_solver = SOLVERfactory<T>::createMYsolver(my_par1, my_par2);

   my_solver->apply_method();

   std::vector<double my_solution = my_solver->getSolution();
   SEXP result = R_NilValue;
   result = PROTECT(Rf_allocVector(REAL, 1));
   SET_VECTOR_ELT(result, 0, Rf_allocVector(REALSXP, my_solution.size()));

    double *rans = REAL(VECTOR_ELT(result, 0));
    for(int i = 0; i < solution.size(); i++)
    {
        rans[i] = solution[i];
    }

  UNPROTECT(1);  
  return result;
}
Are you looking for the answer?
Original Question and Possible Answers can be found on `http://stackoverflow.com`

Question Tags: c++, factory, r, rcpp, unique-ptr

Please login or Register to submit your answer




Primary Sidebar

Tags

Advancements best Business strategies commercial convenience economic Finances Cognitive decline Financial growth firm Future Hidden Gems Home hydration Impact Innovations lighting line of work Mental health Must-See New York City office patronage Productivity profession Profitability tips Profit optimization pursuit recreation Revenue enhancement romance sippy cups social station Technological breakthroughs technology toddlers trading transaction Treasures Uncover undertaking Well-being Wonders Work Young onset dementia

Newsletter

Complete the form below, and we'll send you all the latest news.

Footer

Footer Funnies

Who knew that reading the footer could be such a hilarious adventure? As we navigate websites, books, and documents, we often stumble upon the unassuming space at the bottom, only to discover a treasure trove of amusement. In this side-splitting compilation, we present 100 jokes that celebrate the unsung hero of content – the footer. Get ready to chuckle, giggle, and maybe even snort as we dive into the world of footnotes, disclaimers, and hidden comedic gems. Brace yourself for a wild ride through the footer!

Recent

  • Unveiling the Enigma: Almost-Magical Lamp Lights Highway Turns
  • The Impact of Young Onset Dementia on Employment and Finances: Optimizing Post-Diagnostic Approaches
  • 11 Wonders of 2023 Technological Breakthrough – Unveiling the Future
  • Work from Home and Stay Mentally Sane – Achieve Productivity and Well-being
  • Hidden Gems of New York City – Uncover the Must-See Treasures!

Search

Tags

Advancements best Business strategies commercial convenience economic Finances Cognitive decline Financial growth firm Future Hidden Gems Home hydration Impact Innovations lighting line of work Mental health Must-See New York City office patronage Productivity profession Profitability tips Profit optimization pursuit recreation Revenue enhancement romance sippy cups social station Technological breakthroughs technology toddlers trading transaction Treasures Uncover undertaking Well-being Wonders Work Young onset dementia

Copyright © 2023