i'm using the following c++ code
using namespace std;
#include <iostream>
#include <stdio.h>
#include <opencv/cv.h>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv/highgui.h>
#include <opencv/cv.h>
#include <R.h>
#include <Rinternals.h>
#include <Rmath.h>
extern "C" {
SEXP FiltroGaus(SEXP size1_r, SEXP size2_r, SEXP sigma_r) {
int size1 = INTEGER(size1_r)[0];
int size2 = INTEGER(size2_r)[0];
double sigma = REAL(sigma_r)[0];
}
}
The compilation go without errors but when in R i type
.C("FiltroGaus",3,3,2)
the message is: Errore: INTEGER() can only be applied to a 'integer', not a
'NULL'
if i type .C("FiltroGaus",as.integer(3),as.integer(3),as.double(2))
the message is Errore: INTEGER() can only be applied to a 'integer', not a
'closure'
while if i type .Call("FiltroGaus",as.integer(3),as.integer(3),as.double(2))
the message is
NULL
*** caught segfault ***
address 0x200000be, cause 'memory not mapped'
Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
I now, i need to study and i know also for sure the answer is in some book
(i have lot). I swear i read a lot and i'm still reading, but i really need
help :)
--
View this message in context: http://r.789695.n4.nabble.com/Crash-cause-memory-not-mapped-tp4649141.html
Sent from the R devel mailing list archive at Nabble.com.
Crash - cause 'memory not mapped'
6 messages · niandra, gianluca mastrantonio, Dirk Eddelbuettel +2 more
I'm not an expert, but from what I know you should certainly use the .Call interface when you define a function as you did. The problem is that your function must return a value (of type SEXP) which it does not. If you don't return a value, all bets are off as to what will happen, and if the internal R code uses a pointer to the result of your function, you can easily get memory map errors. HTH, Peter
On Fri, Nov 9, 2012 at 2:31 PM, niandra <gianluca.mastrantonio at yahoo.it> wrote:
i'm using the following c++ code
using namespace std;
#include <iostream>
#include <stdio.h>
#include <opencv/cv.h>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv/highgui.h>
#include <opencv/cv.h>
#include <R.h>
#include <Rinternals.h>
#include <Rmath.h>
extern "C" {
SEXP FiltroGaus(SEXP size1_r, SEXP size2_r, SEXP sigma_r) {
int size1 = INTEGER(size1_r)[0];
int size2 = INTEGER(size2_r)[0];
double sigma = REAL(sigma_r)[0];
}
}
The compilation go without errors but when in R i type
.C("FiltroGaus",3,3,2)
the message is: Errore: INTEGER() can only be applied to a 'integer', not a
'NULL'
if i type .C("FiltroGaus",as.integer(3),as.integer(3),as.double(2))
the message is Errore: INTEGER() can only be applied to a 'integer', not a
'closure'
while if i type .Call("FiltroGaus",as.integer(3),as.integer(3),as.double(2))
the message is
NULL
*** caught segfault ***
address 0x200000be, cause 'memory not mapped'
Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
I now, i need to study and i know also for sure the answer is in some book
(i have lot). I swear i read a lot and i'm still reading, but i really need
help :)
--
View this message in context: http://r.789695.n4.nabble.com/Crash-cause-memory-not-mapped-tp4649141.html
Sent from the R devel mailing list archive at Nabble.com.
______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
the error "memory non mapped" happen also if i use
void FiltroGaus(SEXP size1_r, SEXP size2_r, SEXP sigma_r)
instead
SEXP FiltroGaus(SEXP size1_r, SEXP size2_r, SEXP sigma_r) {
Il giorno 09/nov/2012, alle ore 23:58, Peter Langfelder <peter.langfelder at gmail.com> ha scritto:
I'm not an expert, but from what I know you should certainly use the .Call interface when you define a function as you did. The problem is that your function must return a value (of type SEXP) which it does not. If you don't return a value, all bets are off as to what will happen, and if the internal R code uses a pointer to the result of your function, you can easily get memory map errors. HTH, Peter On Fri, Nov 9, 2012 at 2:31 PM, niandra <gianluca.mastrantonio at yahoo.it> wrote:
i'm using the following c++ code
using namespace std;
#include <iostream>
#include <stdio.h>
#include <opencv/cv.h>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv/highgui.h>
#include <opencv/cv.h>
#include <R.h>
#include <Rinternals.h>
#include <Rmath.h>
extern "C" {
SEXP FiltroGaus(SEXP size1_r, SEXP size2_r, SEXP sigma_r) {
int size1 = INTEGER(size1_r)[0];
int size2 = INTEGER(size2_r)[0];
double sigma = REAL(sigma_r)[0];
}
}
The compilation go without errors but when in R i type
.C("FiltroGaus",3,3,2)
the message is: Errore: INTEGER() can only be applied to a 'integer', not a
'NULL'
if i type .C("FiltroGaus",as.integer(3),as.integer(3),as.double(2))
the message is Errore: INTEGER() can only be applied to a 'integer', not a
'closure'
while if i type .Call("FiltroGaus",as.integer(3),as.integer(3),as.double(2))
the message is
NULL
*** caught segfault ***
address 0x200000be, cause 'memory not mapped'
Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
I now, i need to study and i know also for sure the answer is in some book
(i have lot). I swear i read a lot and i'm still reading, but i really need
help :)
--
View this message in context: http://r.789695.n4.nabble.com/Crash-cause-memory-not-mapped-tp4649141.html
Sent from the R devel mailing list archive at Nabble.com.
______________________________________________ R-devel at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
On 9 November 2012 at 14:31, niandra wrote:
| extern "C" {
| SEXP FiltroGaus(SEXP size1_r, SEXP size2_r, SEXP sigma_r) {
[...]
| The compilation go without errors but when in R i type
| .C("FiltroGaus",3,3,2)
You missed the part in "Writing R Extension" about .C() and .Call()
arguments. You are mixing both approaches here, which usually ends badly.
Do some more reading, and maybe study some existing (simpler) examples /
packages. You really do not need to engage OpenCV headers and libraries
before you understand the basics better.
Dirk
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
On Fri, Nov 9, 2012 at 3:05 PM, gianluca mastrantonio
<gianluca.mastrantonio at yahoo.it> wrote:
the error "memory non mapped" happen also if i use
void FiltroGaus(SEXP size1_r, SEXP size2_r, SEXP sigma_r)
instead
SEXP FiltroGaus(SEXP size1_r, SEXP size2_r, SEXP sigma_r) {
If you use a .Call on a function, the function must return a SEXP, it cannot be have a void return value. Peter
2 days later
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-devel/attachments/20121112/7b1a00c0/attachment.pl>