Displaying 20 results from an estimated 10000 matches similar to: "segfault when calling C code"
2012 Mar 18
2
malloc/calloc/strdup and R's aequivalents
Hello,
when looking at "Writing R Extensions"
with mem-allocation in mind, I wondered,
which functions to use to substitute
malloc(), calloc(), realloc() and strdup() and free().
It looked like Calloc() or R_Calloc() might be useful for
some of my tasks, but when trying to use R_Calloc() for example,
I got some error messages which I don't see where they are coming from.
Maybe I
2004 Jun 11
1
memory allocation and interrupts
Hi,
A recent discussion on the list about tryCatch and signals made me think
about memory allocation and signals in C extension modules. What happens
to the memory allocated by R_alloc and Calloc if the user pressed Ctr-C
during the call? R-ext doesn't seem to discuss this. I'd guess that
R_alloc is interrupt-safe while Calloc is not, but I am not sure. In any
case a paragraph in R-ext
2007 Sep 13
1
chartr better
For example, the following changes are necessary when i convert a
Japanese hiragana into katakana in chattr.
R code:
> chartr("\u3041-\u3093","\u30a1-\u30f3","\u3084\u3063\u305f\u30fc")
--- R-alpha.orig/src/main/character.c 2007-09-05 07:13:27.000000000 +0900
+++ R-alpha/src/main/character.c 2007-09-13 16:10:21.000000000 +0900
@@ -2041,6 +2041,16 @@
2009 Jul 20
3
S_alloc or Calloc for return value
I am trying to write a C function to create a vector of integers that can be
used by the R calling function. I do not know the size of the vector in the
R calling function. (Well, actually, I have an upper limit on the size, but
that is so large that R cannot allocate it. What I'm doing in the function
is to do a sieving procedure, and the result will be small enough to fit
into my
2009 Apr 03
1
Hello! I got error in C - R
Hello,
My name is Ick Hoon Jin and I am Ph. D. student in Texas A & M Univ..
When I run the C embedded in R in the Linux system, I confront the
following error after 6,000 iteration. By googling I found this error is
from the problem in C.
*** caught segfault ***
address (nil), cause 'memory not mapped'
My C code is following:
2004 Sep 14
3
memory allocation questions
Dear R-devel
This one seems a bit arcane for R-help. I very often use R to call routines written in Delphi (son of Pascal), doing "persistent" memory allocation within Delphi. That is, I start R and load the Delphi DLL; then I use .C to call a Delphi routine which allocates a piece of memory X and returns to R a pointer to X; then I do some more stuff in R; then I call another Delphi
2003 Dec 05
3
.C() memory allocation
I would like to retrieve a vector of integers from a call to .C(), but I
don't know its length in advance. How do I do this without making an ugly
safe guess?
My vector is called "sequences".
I am passing the argument sequences = integer(0) in the call to .C(),
then declaring the corresponding argument as int *sequences in my C code.
I tried R_alloc()ing the storage in C and
2005 Jun 13
1
memory allocation problem under linux
I have some compiled code that works under winXp but not under linux (kernel
2.6.10-5). I'm also using R 2.1.0
After debugging, I've discovered that in this code:
#define NMAX 256
long **box;
...
box = (long **)R_alloc(NMAX, sizeof(long *)); //<---HERE THE SIGSEGV
for (i=0; i<NMAX; i++) box[i] = (long *) R_alloc(NMAX, sizeof(long));
inside the *first* call to the
2004 Dec 30
1
optim/vmmin and R_alloc
I am calling 'vmmin' several times from a C function (which is called via
.C). It works very well, except for memory consumption. The cause is that
vmmin allocates memory via R_alloc, and this memory is not freed as vmmin
exits. Instead all the allocated memory is freed on return of the .C
call.
In one application, I have 2000 functions of 500 variables each to
minimize. In each call to
1998 Jan 21
2
alloc
I am trying to get our database interface (PADI) working with R. The code does
some memory allocation and for Splus there is an ifdef which controls whether
malloc or S_alloc is called. I did nm R.binary | grep alloc to see if this was
supported and I find there are some choices:
[2490] | 446036| 272|FUNC |GLOB |0 |7 |R_alloc
[806] | 693956| 312|FUNC |LOCL |0 |7
2008 Apr 14
1
clean-up actions after non-local exits
Dear R-devel,
Some time ago I started a thread that boiled down to clean-up actions after non-local exits in R, see below. I wonder if there has been any progress on this? R-ext 2.6.1 doesn't say much on the subject.
How, for example, do people deal with a situation where their C (C++) function opens a file and then receives a signal or longjump-s on error(), how do they make sure the
2002 Jun 13
3
[R] help debugging segfaults
Hi all,
Thanks to Prof. Ripley, Prof. Gentleman, and Simon Wood (did I miss
anyone?). The problem seemed to have gone away.
Everyone suggested using some malloc debugger (such as Electric Fence). All
I did was following half of what BDR suggested below, i.e., changing all the
S_alloc() calls to Calloc() and Free(). I didn't get to try efence, and the
problem seems to have disappeared!
As
2005 Dec 29
1
Problems with calloc function.
Hi all,
I have a C code in Linux, it has 7 pointers and compile e run OK, but when I
run in R happens problems with calloc function, it returns NULL.
###############################################
> int *temp1,*temp2,*temp3,*temp4;
temp1 = (int *)calloc(col,sizeof(int));
if(temp1 == NULL){
printf("\n\n No Memory1!");
exit(1);
}
temp2 = (int *)calloc(col,sizeof(int));
2011 Jun 09
1
Ctrl-C of functions that allocated mem
Hello,
what happens, when a function (R-extension in C), that allocated memory
(strdup(), malloc()/calloc() and so on), and is used in interactive mode, then
will be stopped via Ctrl-C?
I would assume that there remains allocated memory,
which is not usable and also not accessable (hence no
way to free it).
Are there any mechanisms in R that could help in rolling
back the allocation?
Normally
2006 Apr 13
2
Calloc : syntax error
Hi,
I have issue with Calloc : at the compilation step, gcc tells "error :
syntax error before ')' token".
When I use the classical C calloc... free, everything's fine.
Here's the part of code :
a = (double*) Calloc(*n,sizeof(double));
when i remove this line or replace it with the calloc, it's ok
Hint : In the header file R.h, there's a line :
/* for PROBLEM
2024 Aug 13
1
[PATCH] Reorder calloc arguments
Reordering calloc arguments silences gcc compiler warnings of
latest versions. Spotted with OpenSSH-portable on a Linux system.
Okay?
Index: cipher.c
===================================================================
RCS file: /cvs/src/usr.bin/ssh/cipher.c,v
diff -u -p -u -p -r1.121 cipher.c
--- cipher.c 17 May 2024 02:39:11 -0000 1.121
+++ cipher.c 13 Aug 2024 16:46:00 -0000
@@ -249,7 +249,7
2020 Jun 07
4
[External] Re: use of the tcltk package crashes R 4.0.1 for Windows
I've committed the change to use Free instead of free in tcltk.c and
sys-std.c (r78652 for R-devel, r78653 for R-patched).
We might consider either moving Calloc/Free out of the Windows
remapping or moving the remapping into header files so everything
seeing our header files uses our calloc/free. Either would be less
brittle that the current status.
Best,
luke
On Sun, 7 Jun 2020, peter
2014 Dec 18
2
segfault when trying to allocate a large vector
Dear R contributors,
I'm running into trouble when trying to allocate some large (but in
theory viable) vector in the context of C code bound to R through
.Call(). Here is some sample code summarizing the problem:
SEXP test() {
int size = 10000000;
double largevec[size];
memset(largevec, 0, size*sizeof(double));
return(R_NilValue);
}
If size if small enough (up to 10^6), everything is
2020 Jun 07
3
[External] Re: use of the tcltk package crashes R 4.0.1 for Windows
On Sun, Jun 7, 2020 at 5:53 PM <luke-tierney at uiowa.edu> wrote:
>
> On Sun, 7 Jun 2020, peter dalgaard wrote:
>
> > So this wasn't tested for a month?
> >
> > Anyways, Free() is just free() with a check that we're not freeing a null pointer, followed by setting the pointer to NULL. At that point of tcltk.c, we have
> >
> > for (objc = i = 0;
2015 Jun 17
2
[PATCH] btrfs: keep calloc and its error message match
commit 3f4ba2e98d21746723d291939ccc2e1f1526aa6d
left some error messages unchanged.
Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
---
daemon/btrfs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/daemon/btrfs.c b/daemon/btrfs.c
index 7b14bac..e8059db 100644
--- a/daemon/btrfs.c
+++ b/daemon/btrfs.c
@@ -479,7 +479,7 @@ do_btrfs_subvolume_list (const