Bug 380747

Summary: FIXED IN SVN: CRASH with some objects created by XML package
Product: [Applications] rkward Reporter: RKWard Team <rkward-devel>
Component: generalAssignee: RKWard Team <rkward-devel>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: unspecified   
OS: All   
Latest Commit: Version Fixed In:
Sentry Crash Report:
Attachments: -- Originally posted by (AT sourceforge.net): xavidp -- reporter.00.5.r - the script with tproduces that error. The data file (in xml) will come in another
-- Originally posted by (AT sourceforge.net): xavidp -- R_test.xml - test file with xml format to be stored under the logs_test subdirectory, for the report

Description RKWard Team 2010-05-16 15:40:47 UTC
-- Originally posted by (AT sourceforge.net): xavidp --

-- This ticket was imported from http://sourceforge.net/p/rkward/bugs/67 on 2017-05-30 15:26:48 +0100 --
Hi:

I guess I have some problem with my own R script for processing xml files \(through the usage of R4X package\). But the fact is that RKward crashes every time I attempt to run this script \(reporter.00.5.r, attached\), due to this part: \"xmlTreeParse\(xml\_r\)\"

I get a prop screen with this error:
\-----------------------
\*\*\* caught segfault \*\*\*
address 0x3e, cause \'memory not mapped\'
\-----------------------

However, when I run the same script reporter.00.5.r from the command line, with:

Rscript reporter\_00.5.r

the script seems to read the line with the \"hello\" output in the console, at least.

Oh well, in case this can help the authors of rkward to improve the error detection and warnings for the user, instead of crashing the program. 

More details: RKward: 0.5.2. KDE: 4.4.2, OS: GNU/Linux \(Ubuntu Lucid 10.04\), R: 2.10.1

Fir this script to run, some extra R packages need to be installed: XML, R4X and their dependencies. The commands to install them are included \(commented\) in the reporter.00.5.r script, as weel as the linux dependencies for the xml package to install. -- Labels: data handling --
Comment 1 RKWard Team 2010-05-16 15:40:47 UTC
-- Originally posted by (AT sourceforge.net): xavidp --
reporter.00.5.r - the script with tproduces that error. The data file (in xml) will come in another attachment after this one.
-- Created an attachment --
Comment 2 RKWard Team 2010-05-16 15:43:16 UTC
-- Originally posted by (AT sourceforge.net): xavidp --
R_test.xml - test file with xml format to be stored under the logs_test subdirectory, for the reporter script to work.
-- Created an attachment --
Comment 3 Thomas Friedrichsmeier 2010-05-17 09:40:08 UTC
Thanks for reporting. I can confirm the issue.

The crash happens when RKWard tries to fetch the structure of the object "xml\_parsed" \(the result of an invalid xmlParseTree\(\), the one without validate=TRUE\). Of course, RKWard should not crash on such an object, but in fact we are not the only ones to blame: The object xml\_parsed is simply a broken R object, as also evidenced by str\(xml\_parsed\) \(which throws an error: subscript out of bounds\). Practically it should be possible to avoid the issue by simply using validate=TRUE in all calls to xmlParseTree\(\), thus, hopefully avoiding that a broken object is created in the first place.

\----

Internals: The crash is in RKStructureGetter::getStructureWorker\(\), more specifically while fetching children of a regular container \(do\_cont == TRUE\) around lines 418-443. Always using the last of the three variants of subscripting in this block \(SEXP child = callSimpleFun2 \(double\_brackets\_fun, value, index, R\_BaseEnv\);\) seems to avoid the problem. Before using this unconditionally, we should really time the overhead esp. in package:datasets.
Comment 4 Thomas Friedrichsmeier 2010-05-18 13:23:07 UTC
Hi again,

the problem should be fixed in SVN \(http://p.sf.net/svn\), now. It would be nice, if you could test this, too. An updated binary packages for ubuntu is available from this PPA: https://launchpad.net/~rkward-devel/+archive/rkward-devel .

Thanks for reporting.
Comment 5 Thomas Friedrichsmeier 2010-05-18 13:23:07 UTC
- **assigned_to**: nobody --> tfry
- **summary**: rkward crashes when working with xml files (R4X) --> FIXED IN SVN: CRASH with some objects created by XML package
- **status**: open --> open-fixed
Comment 6 RKWard Team 2010-05-18 16:44:37 UTC
-- Originally posted by (AT sourceforge.net): xavidp --
Thanks heaps\! and you compiled it in a dev, branch for testing at launchpad\! And fixing so quickly\!
Gorgeous\! You \(and rkward\) Rock, Thomas\! :-\)
Many thanks, indeed. 
Comment 7 RKWard Team 2010-05-18 16:44:38 UTC
-- Originally posted by (AT sourceforge.net): xavidp --
- **status**: open-fixed --> closed-fixed