Discussion:
[stats-rosuda-devel] Help with resolving Rserve error: "ignoring SIGPIPE signal"
Purva Kulkarni
2016-10-25 09:06:45 UTC
Permalink
Hello,

I am writing a Java application in IntelliJ IDE. The application uses Rserve() to connect to R and access scripts. The java application communicates many times with R for input and output variables, and everything worked fine. However, today, I recieved the following error while trying to send an REXP object to an Rscript:

Rserve> ignoring SIGPIPE signal

Here is the chance of Java code where the error occurs:
————————————————————————————————————————————————————————————————————————————————————————————————————————
rc = new RConnection();
final String inputFileDirectory = fileName.getParent();
rc.assign("importImagingFile", currentPath.concat("/importImagingFile.R"));
rc.eval("source(importImagingFile)");
rc.assign("currentWorkingDirectory", currentPath);
rc.assign("inputFileDirectory", inputFileDirectory);

rawSpectrumObjects = rc.eval("importImagingFile(inputFileDirectory,currentWorkingDirectory)”); // First Rscript (works successfully)
rawSpectrumListSize = rawSpectrumObjects.asList().size();

rc.assign("plotAverageSpectra", currentPath.concat("/plotAverageSpectra.R")); // REXP object generated from the first script is used as an input for the second script
rc.eval("source(plotAverageSpectra)");
rc.assign("rawSpectrumObjects", rawSpectrumObjects);

REXP averageSpectraObject = rc.eval("plotAverageSpectra(rawSpectrumObjects)”); // Get the " ignoring SIGPIPE signal “ error from this script and the application is halted

// few more R scripts to run

rc.close();

————————————————————————————————————————————————————————————————————————————————————————————————————————

Based on reading a previous post (https://mailman.rz.uni-augsburg.de/pipermail/stats-rosuda-devel/2015q2/002202.html <https://mailman.rz.uni-augsburg.de/pipermail/stats-rosuda-devel/2015q2/002202.html>), I also tried running the application by commenting rc.close(). But this does not solve the purpose.

This is how I start Rserve from the Java application
————————————————————————————————————————————————————————————————————————————————————————————————————————
public class Application {
private static StartRserve sr = new StartRserve();
public static void main(String[] args) throws Exception {
// Start Rserve()
sr.launchRserve("R CMD RServe --vanilla", "--no-save --slave", "--no-save --slave", true);
if(sr.isRserveRunning())
{
// Run the GUI construction in the Event-Dispatching thread for thread-safety
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new GUIMain(“My application"); // Let the constructor do the job
}
});
}
}
}
————————————————————————————————————————————————————————————————————————————————————————————————————————

And, I shutdown Rserve connection on window closing event

————————————————————————————————————————————————————————————————————————————————————————————————————————

private WindowListener exitListener = new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
try {
RConnection c = new RConnection();
c.shutdown();
} catch (RserveException e1) {
e1.printStackTrace();
}
System.exit(0);
}
};
————————————————————————————————————————————————————————————————————————————————————————————————————————

All this worked fine till yesterday. I am not sure why I get this error today? I updated R and Java today, could that be an issue?

Thank you for your help.

Best,
Purva
Purva Kulkarni
2016-10-25 11:20:25 UTC
Permalink
Hello,

Following my previous email, as another option I also tried creating a new RConnection:

——————————————————————————————————————————————————————————————————————————————————————————————————

rc = new RConnection();
final String inputFileDirectory = fileName.getParent();
rc.assign("importImagingFile", currentPath.concat("/importImagingFile.R"));
rc.eval("source(importImagingFile)");
rc.assign("currentWorkingDirectory", currentPath);
rc.assign("inputFileDirectory", inputFileDirectory);

rawSpectrumObjects = rc.eval("importImagingFile(inputFileDirectory,currentWorkingDirectory)”); // First Rscript (works successfully)
rawSpectrumListSize = rawSpectrumObjects.asList().size();



RConnection rcN = new RConnection(); // New RConnection
rcN.assign("plotAverageSpectra", currentPath.concat("/plotAverageSpectra.R")); // REXP object generated from the first script is used as an input for the second script
rcN.eval("source(plotAverageSpectra)");
rcN.assign("rawSpectrumObjects", rawSpectrumObjects);

REXP averageSpectraObject = rcN.eval("plotAverageSpectra(rawSpectrumObjects)”);

// few more Rscript to run

rc.close();
rcN.close();
——————————————————————————————————————————————————————————————————————————————————————————————————

In this case, I do not get the SIGPIPE error, instead I get the following error:

Rserve>RServe(1851,0x7fff7f10a000) malloc: *** error for object 0x7ff9f521ae00: pointer being freed was not allocated
Rserve>*** set a breakpoint in malloc_error_break to debug
assign failed

I am not sure what does this mean.
Thank you for your time.

Best,
Purva
Post by Purva Kulkarni
Hello,
Rserve> ignoring SIGPIPE signal
————————————————————————————————————————————————————————————————————————————————————————————————————————
rc = new RConnection();
final String inputFileDirectory = fileName.getParent();
rc.assign("importImagingFile", currentPath.concat("/importImagingFile.R"));
rc.eval("source(importImagingFile)");
rc.assign("currentWorkingDirectory", currentPath);
rc.assign("inputFileDirectory", inputFileDirectory);
rawSpectrumObjects = rc.eval("importImagingFile(inputFileDirectory,currentWorkingDirectory)”); // First Rscript (works successfully)
rawSpectrumListSize = rawSpectrumObjects.asList().size();
rc.assign("plotAverageSpectra", currentPath.concat("/plotAverageSpectra.R")); // REXP object generated from the first script is used as an input for the second script
rc.eval("source(plotAverageSpectra)");
rc.assign("rawSpectrumObjects", rawSpectrumObjects);
REXP averageSpectraObject = rc.eval("plotAverageSpectra(rawSpectrumObjects)”); // Get the " ignoring SIGPIPE signal “ error from this script and the application is halted
// few more R scripts to run
rc.close();
————————————————————————————————————————————————————————————————————————————————————————————————————————
Based on reading a previous post (https://mailman.rz.uni-augsburg.de/pipermail/stats-rosuda-devel/2015q2/002202.html <https://mailman.rz.uni-augsburg.de/pipermail/stats-rosuda-devel/2015q2/002202.html>), I also tried running the application by commenting rc.close(). But this does not solve the purpose.
This is how I start Rserve from the Java application
————————————————————————————————————————————————————————————————————————————————————————————————————————
public class Application {
private static StartRserve sr = new StartRserve();
public static void main(String[] args) throws Exception {
// Start Rserve()
sr.launchRserve("R CMD RServe --vanilla", "--no-save --slave", "--no-save --slave", true);
if(sr.isRserveRunning())
{
// Run the GUI construction in the Event-Dispatching thread for thread-safety
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new GUIMain(“My application"); // Let the constructor do the job
}
});
}
}
}
————————————————————————————————————————————————————————————————————————————————————————————————————————
And, I shutdown Rserve connection on window closing event
————————————————————————————————————————————————————————————————————————————————————————————————————————
private WindowListener exitListener = new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
try {
RConnection c = new RConnection();
c.shutdown();
} catch (RserveException e1) {
e1.printStackTrace();
}
System.exit(0);
}
};
————————————————————————————————————————————————————————————————————————————————————————————————————————
All this worked fine till yesterday. I am not sure why I get this error today? I updated R and Java today, could that be an issue?
Thank you for your help.
Best,
Purva
Simon Urbanek
2016-10-25 13:34:44 UTC
Permalink
Purva,

if you updated R, please make sure you have re-built all packages including rJava, Rserve and all others. Packages are in general not compatible across R versions. SIGPIPE means that R is trying to write somewhere which doesn't listen - could be an error console, for example as it's trying to tell you what's wrong with R or the packages. You may want to consume the output from Rserve when starting it - please consider looking at the StartRserve.java class supplied with Rserve.

Cheers,
Simon
Post by Purva Kulkarni
Hello,
Rserve> ignoring SIGPIPE signal
————————————————————————————————————————————————————————————————————————————————————————————————————————
rc = new RConnection();
final String inputFileDirectory = fileName.getParent();
rc.assign("importImagingFile", currentPath.concat("/importImagingFile.R"));
rc.eval("source(importImagingFile)");
rc.assign("currentWorkingDirectory", currentPath);
rc.assign("inputFileDirectory", inputFileDirectory);
rawSpectrumObjects = rc.eval("importImagingFile(inputFileDirectory,currentWorkingDirectory)”); // First Rscript (works successfully)
rawSpectrumListSize = rawSpectrumObjects.asList().size();
rc.assign("plotAverageSpectra", currentPath.concat("/plotAverageSpectra.R")); // REXP object generated from the first script is used as an input for the second script
rc.eval("source(plotAverageSpectra)");
rc.assign("rawSpectrumObjects", rawSpectrumObjects);
REXP averageSpectraObject = rc.eval("plotAverageSpectra(rawSpectrumObjects)”); // Get the " ignoring SIGPIPE signal “ error from this script and the application is halted
// few more R scripts to run
rc.close();
————————————————————————————————————————————————————————————————————————————————————————————————————————
Based on reading a previous post (https://mailman.rz.uni-augsburg.de/pipermail/stats-rosuda-devel/2015q2/002202.html), I also tried running the application by commenting rc.close(). But this does not solve the purpose.
This is how I start Rserve from the Java application
————————————————————————————————————————————————————————————————————————————————————————————————————————
public class Application {
private static StartRserve sr = new StartRserve();
public static void main(String[] args) throws Exception {
// Start Rserve()
sr.launchRserve("R CMD RServe --vanilla", "--no-save --slave", "--no-save --slave", true);
if(sr.isRserveRunning())
{
// Run the GUI construction in the Event-Dispatching thread for thread-safety
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new GUIMain(“My application"); // Let the constructor do the job
}
});
}
}
}
————————————————————————————————————————————————————————————————————————————————————————————————————————
And, I shutdown Rserve connection on window closing event
————————————————————————————————————————————————————————————————————————————————————————————————————————
private WindowListener exitListener = new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
try {
RConnection c = new RConnection();
c.shutdown();
} catch (RserveException e1) {
e1.printStackTrace();
}
System.exit(0);
}
};
————————————————————————————————————————————————————————————————————————————————————————————————————————
All this worked fine till yesterday. I am not sure why I get this error today? I updated R and Java today, could that be an issue?
Thank you for your help.
Best,
Purva
_______________________________________________
stats-rosuda-devel mailing list
https://mailman.rz.uni-augsburg.de/mailman/listinfo/stats-rosuda-devel
Loading...