PixInsight Forum (historical)

PixInsight => Bug Reports => Topic started by: David Serrano on 2007 September 17 02:32:32

Title: Hard application crash when resampling image from JS
Post by: David Serrano on 2007 September 17 02:32:32
This is almost the same code I pasted in the "Unable to copy and resample image" message:

Code: [Select]
#include <pjsr/Interpolation.jsh>
#include <pjsr/SampleType.jsh>
#include <pjsr/UndoFlag.jsh>

var w = ImageWindow.activeWindow;
if (w.isNull)
    throw Error ("No image window.");

var v = w.mainView;

var copy_img = new ImageWindow (
    v.image.width, v.image.height,
    v.image.numberOfChannels, v.image.bitsPerSample,
    v.image.sampleType == SampleType_Real,
    true, "foobar23204"
);
copy_img.show();
with (copy_img.mainView) {
    beginProcess (UndoFlag_NoSwapFile);
    //image.apply (v.image); // crash
    //image.assign (v.image); // crash
    //image.clonePixelData (v.image); // err
    //var ap = new Array; v.image.getPixels (ap); image.setPixels (ap); // crash
    //image.transfer (v.image); // err
    image.resample (640, 480, Interpolation_BicubicBSpline);
    endProcess();
}

//copy_img = null;
gc();


The important difference is that I moved the "image.resample" line before the endProcess one. When uncommenting one of the five previous lines, the behaviour of the application is as noted: crash in 3 of the cases and error in the other 2. If no line is uncommented, the application crashes too.

The main PixInsight window disappears and the console from which I run the application says:

Code: [Select]
terminate called after throwing an instance of 'pcl::EUnixSegmentationViolation'
/usr/bin/PixInsight: line 5:  6389 Aborted                 /usr/lib/pixinsight/PixInsight32 $*
Title: Hard application crash when resampling image from JS
Post by: Juan Conejero on 2007 September 17 03:12:50
Hi David,

This is not a bug, actually, but just that you're fooling memory management routines  8)

I have explained it on this thread (http://pleiades-astrophoto.com/forum/viewtopic.php?p=1003&sid=5b467a1668ab56a319707ec603eb6f69#1003) of the Software Development section. The problem's here:

Code: [Select]
image.resample (640, 480, Interpolation_BicubicBSpline);

and is that you're trying to allocate something like 4x10^12 bytes, which is funny  :lol: