octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Octave-bug-tracker] [bug #47381] unwind_protect_cleanup block not run f


From: Rik
Subject: [Octave-bug-tracker] [bug #47381] unwind_protect_cleanup block not run for some errors in C++ code
Date: Thu, 10 Mar 2016 18:06:13 +0000
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0

URL:
  <http://savannah.gnu.org/bugs/?47381>

                 Summary: unwind_protect_cleanup block not run for some errors
in C++ code
                 Project: GNU Octave
            Submitted by: rik5
            Submitted on: Thu 10 Mar 2016 10:06:12 AM PST
                Category: Interpreter
                Severity: 4 - Important
                Priority: 5 - Normal
              Item Group: Incorrect Result
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
                 Release: dev
        Operating System: GNU/Linux

    _______________________________________________________

Details:

The purpose of the unwind_protect/unwind_protect_cleanup construct is to be
able to trap errors and recover if necessary.  Unfortunately, I have
discovered at least one exception to this when printing.

I've constructed a test script which tests a path of multiple unwind blocks.


function tst_mult_unwind
unwind_protect
  disp "In unwind block 1");
  x = 1
  subfun1 (x)
unwind_protect_cleanup
  disp "In cleanup block 1");
  x = -x
end_unwind_protect
endfunction

function x = subfun1 (x)
  unwind_protect
    disp "In unwind block 2");
    sombrero;
    x++
    x = subfun2(x)
  unwind_protect_cleanup
    disp "In cleanup block 2");
    x = -2
  end_unwind_protect
endfunction

function x = subfun2 (x)
  unwind_protect
    disp "In unwind block 3");
    # Comment/Uncomment this line to create problem
    #print -dfoo tst.eps
    x++
    error ("error from subfun2");
  unwind_protect_cleanup
    disp "In cleanup block 3");
    x = -3
  end_unwind_protect
endfunction


When run without the call to print I see that each cleanup block is executed.


tst_mult_unwind
In unwind block 1)
x =  1
In unwind block 2)
ans =  1
In unwind block 3)
ans =  2
error: error from subfun2
error: called from
    tst_mult_unwind>subfun2 at line 29 column 5
    tst_mult_unwind>subfun1 at line 17 column 7
    tst_mult_unwind at line 5 column 3
In cleanup block 3)
x = -3
In cleanup block 2)
x = -2
In cleanup block 1)
x = -1


However, when I uncomment the line which calls print I get


tst_mult_unwind
Unknown device: foo
sfopen: gs_parse_file_name failed.
sfopen: gs_parse_file_name failed.
  ./base/gsicc_manage.c:1084: gsicc_open_search(): Could not find
default_gray.icc 
| ./base/gsicc_manage.c:1690: gsicc_set_device_profile(): cannot find device
profile
Unrecoverable error: unknownerror in .special_op
Operand stack:
    defaultdevice
Unrecoverable error: undefined in .uninstallpagedevice
Operand stack:
    defaultdevice
warning: broken pipe
In unwind block 1)
x =  3
In unwind block 2)


The ordering of message in stdout is slightly messed up, but you can see that
no cleanup blocks are ever executed.

This isn't about merely having C++ code.  I used mkoctfile to build a DLDFCN
which throws an error.  Calling that function in place of print works
correctly.

The first problem is why the Octave interpreter is not working correctly when
print eventually invokes __osmesa_print__ at the bottom of __opengl_print__.m.
 The second question is whether there are other instances where this might
happen such as GraphicsMagick or other DLDFCN libraries.

Incidentally, I tested with 'graphics_toolkit gnuplot' and then the script
passes.




    _______________________________________________________

File Attachments:


-------------------------------------------------------
Date: Thu 10 Mar 2016 10:06:12 AM PST  Name: tst_mult_unwind.m  Size: 694B  
By: rik5

<http://savannah.gnu.org/bugs/download.php?file_id=36595>
-------------------------------------------------------
Date: Thu 10 Mar 2016 10:06:12 AM PST  Name: throwerr.cc  Size: 318B   By:
rik5

<http://savannah.gnu.org/bugs/download.php?file_id=36596>
-------------------------------------------------------
Date: Thu 10 Mar 2016 10:06:12 AM PST  Name: tst_unwind.m  Size: 218B   By:
rik5

<http://savannah.gnu.org/bugs/download.php?file_id=36597>

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?47381>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]