panic: Segmentation violation -- stopping myself...

View: New views
10 Messages — Rating Filter:   Alert me  

panic: Segmentation violation -- stopping myself...

by Ian Nield :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Implementation:  GNU Octave v 3.0.0 Windows XP

Error message:
panic: Segmentation violation -- stopping myself...
attempting to save variables to `octave-core'...
save to `octave-core' complete

I offered to held solve this QP problem for a colleague at work.
Attached is the code and data.  Seems to generate the "panic" message
after about the third main loop through the solver.


Does anyone have any suggestions (I admit the code could be a lot tidier!)

Regards,


Ian Nield






load -ascii Eqty.csv
r = Eqty;
dc = mean(r);
[m, n] = size(r)

for icol = 1:n
    for jrow = 1:m
       r(jrow,icol) = r(jrow, icol) - dc(icol);
     endfor
  endfor

cr = cov(r);
mcr = -1 * cr;

q = zeros(n,1);
xlower = zeros(n,1);
xupper = ones(n,1)/10;
xstart = ones(n,1)/n;
b = [1];
A = ones(1,n);
Ain = A;

W = dc';

ctype = "S";
vartype = repmat("C", n, 1);
param.msglev = 2;

# predefining information parameters for qp
solveiter = 0;
info = 0;

[xopt, fmin, status, xtra] = glpk(W, A, b, xlower, xupper, ctype, vartype, -1, param)

[x, obj, info, lambda] = qp(xstart, cr, q, A, b, xlower, xupper, [],Ain,[]);

if ( (solveiter == 200) && (info == 3) )
   xstart = x;
   [x, obj, info, lambda] = qp(xstart, cr, q, A, b, xlower, xupper, [],Ain,[]);
   info
endif

xmin = x;
xstart = ones(n,1)/n;

[x, obj, info, lambda] = qp(xstart, mcr, q, A, b, xlower, xupper, [],Ain,[]);

xstart = x;

[x, obj, info, lambda] = qp(xstart, mcr, q, A, b, xlower, xupper, [],Ain,[]);

info

xmax = x;

rmin = sqrt(xmin' * cr * xmin);
rmax = sqrt(xmax' * cr * xmax);

retmin = dc * xmin
retmax = fmin
retrange = linspace(retmin, retmax, 11);

rrange = linspace(rmin, rmax, 10);
rmat = zeros(n,10);

rmat(:, 1) = xmin;
rmat(:,10) = xmax;

disp("Running main portfolio loop...")

A = ones(2,n);
b = ones(2,1);
A(2,:) = dc';

for icol = 1:11

#   q = 0.5*rrange(icol)^2*ones(n,1);
#   A(2,:) = (rrange(icol)^2/n)*ones(1,n)
   b(2,1) = retrange(icol);
   xstart = ones(n,1)/n;
   [x, obj, info, lambda] = qp(xstart, cr, q, A, b, xlower, xupper, [], Ain,[]);

   if ( (solveiter == 200) && (info =3) )
      xstart = x;
      [x, obj, info, lambda] = qp(xstart, cr, q, A, b, xlower, xupper, [],Ain,[]);
      info
   endif

   rmat(:, icol) = x;
   save -ascii EqtyRslt.csv rmat rrange retrange dc cr;

   disp(icol)
endfor

rrange = sqrt(12)*rrange;

save -ascii EqtyRslt.csv rmat rrange retrange dc cr;

_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www.cae.wisc.edu/mailman/listinfo/bug-octave

Eqty.csv (379K) Download Attachment

panic: Segmentation violation -- stopping myself...

by John W. Eaton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 23-Apr-2008, Ian Nield wrote:

| Implementation:  GNU Octave v 3.0.0 Windows XP
|
| Error message:
| panic: Segmentation violation -- stopping myself...
| attempting to save variables to `octave-core'...
| save to `octave-core' complete
|
| I offered to held solve this QP problem for a colleague at work.
| Attached is the code and data.  Seems to generate the "panic" message
| after about the third main loop through the solver.
|
|
| Does anyone have any suggestions (I admit the code could be a lot tidier!)

I'm unable to duplicate this problem with Octave 3.0.0 on a Debian
system, so maybe the bug is somehow only triggered on Windows systems?
Can anyone confirm?

jwe
_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www.cae.wisc.edu/mailman/listinfo/bug-octave

Re: panic: Segmentation violation -- stopping myself...

by Michael Goffioul-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Apr 23, 2008 at 6:56 PM, John W. Eaton <jwe@...> wrote:

>
> On 23-Apr-2008, Ian Nield wrote:
>
>  | Implementation:  GNU Octave v 3.0.0 Windows XP
>  |
>  | Error message:
>  | panic: Segmentation violation -- stopping myself...
>  | attempting to save variables to `octave-core'...
>  | save to `octave-core' complete
>  |
>  | I offered to held solve this QP problem for a colleague at work.
>  | Attached is the code and data.  Seems to generate the "panic" message
>  | after about the third main loop through the solver.
>  |
>  |
>  | Does anyone have any suggestions (I admit the code could be a lot tidier!)
>
>  I'm unable to duplicate this problem with Octave 3.0.0 on a Debian
>  system, so maybe the bug is somehow only triggered on Windows systems?
>  Can anyone confirm?

Yes (tested with current development code). Using MSVC debugger, I could
catch an access violation in __qp__.cc around line 362: Wact(i) - Wact(i+1)

As I don't understand that code, I'll just give here the state of some variables
when the problem occurs. I hope that someone will get a better insight of
what's going on:

Wact -> 174x1 column vector
i = 173 ==> hence Wact(i+1) is an access violation
which_eig = 152
n_act = 176
n_eq = 2

Michael.
_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www.cae.wisc.edu/mailman/listinfo/bug-octave

Re: panic: Segmentation violation -- stopping myself...

by John W. Eaton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 23-Apr-2008, Michael Goffioul wrote:

| On Wed, Apr 23, 2008 at 6:56 PM, John W. Eaton <jwe@...> wrote:
| >
| > On 23-Apr-2008, Ian Nield wrote:
| >
| >  | Implementation:  GNU Octave v 3.0.0 Windows XP
| >  |
| >  | Error message:
| >  | panic: Segmentation violation -- stopping myself...
| >  | attempting to save variables to `octave-core'...
| >  | save to `octave-core' complete
| >  |
| >  | I offered to held solve this QP problem for a colleague at work.
| >  | Attached is the code and data.  Seems to generate the "panic" message
| >  | after about the third main loop through the solver.
| >  |
| >  |
| >  | Does anyone have any suggestions (I admit the code could be a lot tidier!)
| >
| >  I'm unable to duplicate this problem with Octave 3.0.0 on a Debian
| >  system, so maybe the bug is somehow only triggered on Windows systems?
| >  Can anyone confirm?
|
| Yes (tested with current development code). Using MSVC debugger, I could
| catch an access violation in __qp__.cc around line 362: Wact(i) - Wact(i+1)
|
| As I don't understand that code, I'll just give here the state of some variables
| when the problem occurs. I hope that someone will get a better insight of
| what's going on:
|
| Wact -> 174x1 column vector
| i = 173 ==> hence Wact(i+1) is an access violation
| which_eig = 152
| n_act = 176
| n_eq = 2

I think the following patch will fix the prolem.

Thanks,

jwe



# HG changeset patch
# User John W. Eaton <jwe@...>
# Date 1208983180 14400
# Node ID 6f2b2cc4b957669d4f7b80622cc600b5cd10a361
# Parent  13820b9f5fd9c15cea7639bf9b71ffb34c2fa61d
__qp__.cc: avoid bounds error when removing constraint from active set

diff --git a/src/ChangeLog b/src/ChangeLog
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,4 +1,7 @@ 2008-04-23  John W. Eaton  <jwe@...
 2008-04-23  John W. Eaton  <jwe@...>
+
+ * DLD-FUNCTIONS/__qp__.cc (qp): Avoid bounds error when removing
+ constraint from active set.
 
  * lex.l (text_yyinput): New function.  Use it in place of yyinput.
  (next_token_is_sep_op, scan_for_comments, eat_whitespace,
diff --git a/src/DLD-FUNCTIONS/__qp__.cc b/src/DLD-FUNCTIONS/__qp__.cc
--- a/src/DLD-FUNCTIONS/__qp__.cc
+++ b/src/DLD-FUNCTIONS/__qp__.cc
@@ -357,6 +357,7 @@ qp (const Matrix& H, const ColumnVector&
   // At least one multiplier is negative, we
   // remove it from the set.
 
+  n_act--;
   for (octave_idx_type i = which_eig; i < n_act - n_eq; i++)
     {
       Wact(i) = Wact(i+1);
@@ -364,7 +365,6 @@ qp (const Matrix& H, const ColumnVector&
  Aact(n_eq+i,j) = Aact(n_eq+i+1,j);
       bact(n_eq+i) = bact(n_eq+i+1);
     }
-  n_act--;
 
   // Resizing the active set.
   Wact.resize (n_act-n_eq);

_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www.cae.wisc.edu/mailman/listinfo/bug-octave

Re: panic: Segmentation violation -- stopping myself...

by ruya :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I am new to octave and I am using windows xp platform at the moment. How do I apply this patch?

Thanks


Ian Nield wrote:
Implementation:  GNU Octave v 3.0.0 Windows XP

Error message:
panic: Segmentation violation -- stopping myself...
attempting to save variables to `octave-core'...
save to `octave-core' complete

I offered to held solve this QP problem for a colleague at work.
Attached is the code and data.  Seems to generate the "panic" message
after about the third main loop through the solver.


Does anyone have any suggestions (I admit the code could be a lot tidier!)

Regards,


Ian Nield





 
load -ascii Eqty.csv
r = Eqty;
dc = mean(r);
[m, n] = size(r)

for icol = 1:n
    for jrow = 1:m
       r(jrow,icol) = r(jrow, icol) - dc(icol);
     endfor
  endfor

cr = cov(r);
mcr = -1 * cr;

q = zeros(n,1);
xlower = zeros(n,1);
xupper = ones(n,1)/10;
xstart = ones(n,1)/n;
b = [1];
A = ones(1,n);
Ain = A;

W = dc';

ctype = "S";
vartype = repmat("C", n, 1);
param.msglev = 2;

# predefining information parameters for qp
solveiter = 0;
info = 0;

[xopt, fmin, status, xtra] = glpk(W, A, b, xlower, xupper, ctype, vartype, -1, param)

[x, obj, info, lambda] = qp(xstart, cr, q, A, b, xlower, xupper, [],Ain,[]);

if ( (solveiter == 200) && (info == 3) )
   xstart = x;
   [x, obj, info, lambda] = qp(xstart, cr, q, A, b, xlower, xupper, [],Ain,[]);
   info
endif

xmin = x;
xstart = ones(n,1)/n;

[x, obj, info, lambda] = qp(xstart, mcr, q, A, b, xlower, xupper, [],Ain,[]);

xstart = x;

[x, obj, info, lambda] = qp(xstart, mcr, q, A, b, xlower, xupper, [],Ain,[]);

info

xmax = x;

rmin = sqrt(xmin' * cr * xmin);
rmax = sqrt(xmax' * cr * xmax);

retmin = dc * xmin
retmax = fmin
retrange = linspace(retmin, retmax, 11);

rrange = linspace(rmin, rmax, 10);
rmat = zeros(n,10);

rmat(:, 1) = xmin;
rmat(:,10) = xmax;

disp("Running main portfolio loop...")

A = ones(2,n);
b = ones(2,1);
A(2,:) = dc';

for icol = 1:11

#   q = 0.5*rrange(icol)^2*ones(n,1);
#   A(2,:) = (rrange(icol)^2/n)*ones(1,n)
   b(2,1) = retrange(icol);
   xstart = ones(n,1)/n;
   [x, obj, info, lambda] = qp(xstart, cr, q, A, b, xlower, xupper, [], Ain,[]);

   if ( (solveiter == 200) && (info =3) )
      xstart = x;
      [x, obj, info, lambda] = qp(xstart, cr, q, A, b, xlower, xupper, [],Ain,[]);
      info
   endif

   rmat(:, icol) = x;
   save -ascii EqtyRslt.csv rmat rrange retrange dc cr;

   disp(icol)
endfor

rrange = sqrt(12)*rrange;

save -ascii EqtyRslt.csv rmat rrange retrange dc cr;

_______________________________________________
Bug-octave mailing list
Bug-octave@octave.org
https://www.cae.wisc.edu/mailman/listinfo/bug-octave

Re: panic: Segmentation violation -- stopping myself...

by Michael Goffioul-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Jun 4, 2008 at 5:27 PM, ruya <rmlopes@...> wrote:
>
> Hi,
>
> I am new to octave and I am using windows xp platform at the moment. How do
> I apply this patch?

What version do you use? This patch has been included in 3.0.1 releases.

Michael.
_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www.cae.wisc.edu/mailman/listinfo/bug-octave

Re: panic: Segmentation violation -- stopping myself...

by ruya :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello,

I've checked and I am using version 3.0.1. Maybe it is not the same exact problem. Here is what happens: I double clilck Octave icon to start the application. Then, it displays some start info. The last thing that shows before the segmentation violation is "MSYS shell available (<path to msys folder>)". and then BUM....

Thank you,
Rui


Michael Goffioul-2 wrote:
On Wed, Jun 4, 2008 at 5:27 PM, ruya <rmlopes@student.dei.uc.pt> wrote:
>
> Hi,
>
> I am new to octave and I am using windows xp platform at the moment. How do
> I apply this patch?

What version do you use? This patch has been included in 3.0.1 releases.

Michael.
_______________________________________________
Bug-octave mailing list
Bug-octave@octave.org
https://www.cae.wisc.edu/mailman/listinfo/bug-octave

Re: panic: Segmentation violation -- stopping myself...

by Michael Goffioul-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, Jun 5, 2008 at 11:59 AM, ruya <rmlopes@...> wrote:
>
> Hello,
>
> I've checked and I am using version 3.0.1. Maybe it is not the same exact
> problem. Here is what happens: I double clilck Octave icon to start the
> application. Then, it displays some start info. The last thing that shows
> before the segmentation violation is "MSYS shell available (<path to msys
> folder>)". and then BUM....

Indeed, it's not the same problem as the original post in this thread.
This is typically due to old java version installed (in case you selected
JHandles as default graphics backend). Be sure to use at least java-1.5.

Michael.
_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www.cae.wisc.edu/mailman/listinfo/bug-octave

Re: panic: Segmentation violation -- stopping myself...

by ruya :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

That's it. I had only jre1.4 on this PC.

Thanks,
Rui


Michael Goffioul-2 wrote:
On Thu, Jun 5, 2008 at 11:59 AM, ruya <rmlopes@student.dei.uc.pt> wrote:
>
> Hello,
>
> I've checked and I am using version 3.0.1. Maybe it is not the same exact
> problem. Here is what happens: I double clilck Octave icon to start the
> application. Then, it displays some start info. The last thing that shows
> before the segmentation violation is "MSYS shell available (<path to msys
> folder>)". and then BUM....

Indeed, it's not the same problem as the original post in this thread.
This is typically due to old java version installed (in case you selected
JHandles as default graphics backend). Be sure to use at least java-1.5.

Michael.
_______________________________________________
Bug-octave mailing list
Bug-octave@octave.org
https://www.cae.wisc.edu/mailman/listinfo/bug-octave

Re: panic: Segmentation violation -- stopping myself...

by Michael Goffioul-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

This typically occurs with an old java version (1.4.x). Upgrade your java
and try again.

Michael.


On Thu, Jun 5, 2008 at 9:05 AM, ruya <rmlopes@...> wrote:

>
> Hello,
>
> I've checked and I am using version 3.0.1. Maybe it is not the same exact
> problem. Here is what happens: I double clilck Octave icon to start the
> application. Then, it displays some start info. The last thing that shows
> before the segmentation violation is "MSYS shell available (<path to msys
> folder>)". and then BUM....
>
> Thank you,
> Rui
>
>
>
> Michael Goffioul-2 wrote:
>>
>> On Wed, Jun 4, 2008 at 5:27 PM, ruya <rmlopes@...> wrote:
>>>
>>> Hi,
>>>
>>> I am new to octave and I am using windows xp platform at the moment. How
>>> do
>>> I apply this patch?
>>
>> What version do you use? This patch has been included in 3.0.1 releases.
>>
>> Michael.
>> _______________________________________________
>> Bug-octave mailing list
>> Bug-octave@...
>> https://www.cae.wisc.edu/mailman/listinfo/bug-octave
>>
>>
>
> --
> View this message in context: http://www.nabble.com/panic%3A-Segmentation-violation----stopping-myself...-tp16859691p17663545.html
> Sent from the Octave - Bugs mailing list archive at Nabble.com.
>
> _______________________________________________
> Bug-octave mailing list
> Bug-octave@...
> https://www.cae.wisc.edu/mailman/listinfo/bug-octave
>
_______________________________________________
Bug-octave mailing list
Bug-octave@...
https://www.cae.wisc.edu/mailman/listinfo/bug-octave