Re: [Rd] [R] Segfault in pure R code

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Tue 12 Dec 2006 - 23:01:14 GMT

That's in the memory manager and indicates prior memory corruption. Please re-run under valgrind, plus gctorture(TRUE) if needed.

However, I would start by seeing if this occurs in a single-byte domain if this was in a UTF-8 domain. Experience suggests that we have some flakier code in the less-used MBCS pathways.

On Tue, 12 Dec 2006, Gran Brostrm wrote:

> I tried once more under the debugger, and
>
> ++++++++++++++++++++++++++++++++++++++++++
> gb@kasparov:~/R/BEMANNING/Doc$ R -d gdb
> GNU gdb 6.5-debian
> Copyright (C) 2006 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and you are
> welcome to change it and/or distribute copies of it under certain conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB. Type "show warranty" for details.
> This GDB was configured as "i486-linux-gnu"...Using host libthread_db
> library "/lib/tls/i686/cmov/libthread_db.so.1".
>
> (gdb) run
> Starting program: /usr/local/lib/R/bin/exec/R
> Failed to read a valid object file image from memory.
>
> R version 2.4.0 Patched (2006-10-29 r39744)
> Copyright (C) 2006 The R Foundation for Statistical Computing
> ISBN 3-900051-07-0
>
> R is free software and comes with ABSOLUTELY NO WARRANTY.
> You are welcome to redistribute it under certain conditions.
> Type 'license()' or 'licence()' for distribution details.
>
> Natural language support but running in an English locale
>
> R is a collaborative project with many contributors.
> Type 'contributors()' for more information and
> 'citation()' on how to cite R or R packages in publications.
>
> Type 'demo()' for some demos, 'help()' for on-line help, or
> 'help.start()' for an HTML browser interface to help.
> Type 'q()' to quit R.
>
> [Previously saved workspace restored]
>
>> library(xtable)
>> ?xtable)
> Error: syntax error in "?xtable)"
>> ?xtable
>> help.start()
> Making links in per-session dir ...
> If '/usr/bin/firefox' is already running, it is *not* restarted, and
> you must switch to its window.
> Otherwise, be patient ...
>> library(bemanning)
>> load("bemanning07-32.rda")
>> courses("Ingrid")
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x080f5026 in R_gc_internal (size_needed=17588127) at memory.c:1313
> 1313 PROCESS_NODES();
> (gdb)
> ++++++++++++++++++++++++++++++++++++++++++++
>
> How do I continue?
>
> Gran
>
> On 12/12/06, Gran Brostrm <goran.brostrom@gmail.com> wrote:
>> On 12/12/06, Peter Dalgaard <p.dalgaard@biostat.ku.dk> wrote:
>>> Gran Brostrm wrote:
>>>> I just caught a segfault:
>>>>
>>>>
>>>>> courses("Ingrid")
>>>>>
>>>>
>>>> *** caught segfault ***
>>>> address 0x99b279c, cause 'memory not mapped'
>>>>
>>>> Traceback:
>>>> 1: structure(y, class = oldClass(x), row.names = attr(x, "row.names"))
>>>> 2: `[.data.frame`(gudata, -(1:5))
>>>> 3: gudata[-(1:5)]
>>>> 4: names(gudata[-(1:5)])
>>>> 5: inherits(x, "factor")
>>>> 6: is.factor(table)
>>>> 7: match(x, table, nomatch = 0)
>>>> 8: who %in% names(gudata[-(1:5)])
>>>> 9: courses("Ingrid")
>>>>
>>>> when running a function 'courses' in an R package without compiled
>>>> code. Is this "possible"? I have got many segfaults when testing my
>>>> own packages, but it has always been caused by stupidities in C or
>>>> Fortran code, never with pure R code.
>>>>
>>>> So, before I start debugging, I'd like to know if a segfault in pure R
>>>> code indicates a bug in R itself, or if it can be in my function?
>>>>
>>>>
>>> By definition, reproducible segfaults in R code are bugs in R, unless
>>> caused by abuse of .C calls or similar. (Irreproducible ones are often
>>> hardware faults.)
>>>
>>> However, at least presently, you are the only one with a handle on the
>>> bug. So either you get to do the debugging or you have to provide
>>> something that others can reproduce.
>>>
>>> Astarting point could be to run R under the debugger (R -d gdb) and
>>> generate a C backtrace, then look at the variables involved.
>>
>> Thanks, Peter,
>>
>> the error is reproducible. The full session is
>>
>> +++++++++++++++++++++++++++++++++++++++++
>> gb@kasparov:~/R/BEMANNING/Doc$ R
>>
>> R version 2.4.0 Patched (2006-10-29 r39744)
>> Copyright (C) 2006 The R Foundation for Statistical Computing
>> ISBN 3-900051-07-0
>>
>> R is free software and comes with ABSOLUTELY NO WARRANTY.
>> You are welcome to redistribute it under certain conditions.
>> Type 'license()' or 'licence()' for distribution details.
>>
>> Natural language support but running in an English locale
>>
>> R is a collaborative project with many contributors.
>> Type 'contributors()' for more information and
>> 'citation()' on how to cite R or R packages in publications.
>>
>> Type 'demo()' for some demos, 'help()' for on-line help, or
>> 'help.start()' for an HTML browser interface to help.
>> Type 'q()' to quit R.
>>
>> [Previously saved workspace restored]
>>
>>> library(xtable)
>>> ?xtable)
>> Error: syntax error in "?xtable)"
>>> ?xtable
>>> help.start()
>> Making links in per-session dir ...
>> If '/usr/bin/firefox' is already running, it is *not* restarted, and
>> you must switch to its window.
>> Otherwise, be patient ...
>>> library(bemanning)
>>> load("bemanning07-32.rda")
>>> courses("Ingrid")
>>
>> *** caught segfault ***
>> address 0x99b279c, cause 'memory not mapped'
>>
>> Traceback:
>> 1: structure(y, class = oldClass(x), row.names = attr(x, "row.names"))
>> 2: `[.data.frame`(gudata, -(1:5))
>> 3: gudata[-(1:5)]
>> 4: names(gudata[-(1:5)])
>> 5: inherits(x, "factor")
>> 6: is.factor(table)
>> 7: match(x, table, nomatch = 0)
>> 8: who %in% names(gudata[-(1:5)])
>> 9: courses("Ingrid")
>>
>> Possible actions:
>> 1: abort (with core dump)
>> 2: normal R exit
>> 3: exit R without saving workspace
>> 4: exit R saving workspace
>> Selection:
>> +++++++++++++++++++++++++++++++++++++++++++++
>>
>> Notes:
>>
>> 1. Tried to remove one line at a time, but then no error.
>> 2. R -d gdb: No errors
>> 3. Starting with 'R --vanilla': No errors.
>>
>> i.e., it seems as if my previously saved workspace '.RData' is part of
>> the error.
>> Could it be corrupt and cause a segfault in a bug free R?
>>
>> I'll try to build a newer version of R and check (but not tonight).
>>
>> Gran
>>
>>> (Further discussion should probably go on r-devel instead of r-help).
>>>
>>> -p
>>>
>>>> I have used 'courses' many times before without problems.
>>>>
>>>> Thanks,
>>>>
>>>> Gran
>>>> ++++++++++++++++++++++++++++++++++++++
>>>>
>>>>> sessionInfo()
>>>>>
>>>> R version 2.4.0 Patched (2006-10-29 r39744)
>>>> i686-pc-linux-gnu
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>> --
>> Gran Brostrm
>>
>
>
>

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595


______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel

Received on Wed Dec 13 23:03:05 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 15 Dec 2006 - 18:31:01 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.