patchGNU Octave - Patches: patch #8768, new field for stack info in...

 
 

patch #8768: new field for stack info in structure passed to error handler of cellfun

Submitter:  Olaf Till <i7tiol>
Submitted:  Mon 12 Oct 2015 10:48:27 AM UTC
   
 
Category:  Core : new feature Priority:  3 - Low
Status:  Need Info Privacy:  Public
Assigned to:  i7tiol Open/Closed:  Open
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 20 Jan 2020 06:00:57 PM UTC, comment #3: 


> Olaf, is this patch still relevant for you/Octave?


Well, the situation is unchanged...

If this change should be done, it won't be the first thing for me to use once I'm able again to attend to the parallel package. But I think returning error stack information would be reasonable in general.

But I understand that we haven't enough resources to care for all such small out-of-the-way changes...

Olaf Till <i7tiol>
Group Member
Sat 18 Jan 2020 10:33:52 AM UTC, comment #2: 

Review for Octave 6.

This patch is a one liner, as Olaf said, thus post it here:


# HG changeset patch
# User Olaf Till <olaf.till@uni-jena.de>
# Date 1444646177 -7200
#      Mon Oct 12 12:36:17 2015 +0200
# Node ID c59a42925f83e8d2a4e35e8bf9b55f55f7d2e366
# Parent  3339c9bdfe6a6b5cbb1c4048f36367f812fc6fac
libinterp/corefcn/cellfun.cc: error handler gets stack info.

diff -r 3339c9bdfe6a -r c59a42925f83 libinterp/corefcn/cellfun.cc
--- a/libinterp/corefcn/cellfun.cc        Sat Oct 03 07:32:50 2015 +0200
+++ b/libinterp/corefcn/cellfun.cc        Mon Oct 12 12:36:17 2015 +0200
@@ -95,6 +95,7 @@
           msg.assign ("index",
                       static_cast<double> (count
                                            + static_cast<octave_idx_type>(1)));
+          msg.assign ("stack", octave_value (last_error_stack ()));

           octave_value_list errlist = inputlist;
           errlist.prepend (msg);


In recent Octave dev, it could be applied to the following line:

https://hg.savannah.gnu.org/hgweb/octave/file/6a37ebaeeb28/libinterp/corefcn/cellfun.cc#l108

Olaf, is this patch still relevant for you/Octave?

Kai Torben Ohlhus <siko1056>
Group Member
Wed 06 Jul 2016 01:52:56 PM UTC, comment #1: 

Olaf, if Matlab doesn't have this feature, do they have a way to solve the problems that you mentioned with parcellfun and netcellfun?

Lachlan Andrew <lachlan>
Mon 12 Oct 2015 10:48:27 AM UTC, original submission:  

'cellfun' can be passed an error handler. In case the user function produces an error, the error handler is called with the arguments of the user function and an additional structure with error information. The return value of the error handler is returned as an element of the return values of cellfun.

The structure with error information, passed to the error handler, contains the fields 'identifier' (error identifier), 'message' (error message), and 'index' (index of argument set for user function). However, it does not contain the error stack. This hinders finding the erroneous code in the user function.

This is not a big issue if only cellfun is used, since one can call it without an error handler to see the error stack of the user function directly. But in parallel execution, as with parcellfun or the new netcellfun, the errors of the child processes are caught and their messages can only be seen by examining the output of the error handler. It's no great problem to pass stack information to the error handler in parcellfun and netcellfun. But in some cases (chunked evaluation) these functions internally call cellfun, so for consistency, stack information should also be passed to the error handler by cellfun, so that this information is available to parcellfun and netcellfun. The stack can be passed in the field 'stack', and can be the same as the corresponding field returned by the function 'lasterror'.

Matlabs cellfun does not set the field 'stack' for the error handler, so the main problem should be to decide if we want to set it or not. The implementation itself is only one line, so I barely see the need to provide a changeset, but here it is.

Olaf Till <i7tiol>
Group Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #35164:  err_handler_stack_info.cset added by i7tiol (822B - application/octet-stream)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by siko1056 (Posted a comment)
  • -email is unavailable- added by lachlan (Posted a comment)
  • -email is unavailable- added by i7tiol (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-01-18 siko1056 CategoryNone Core : new feature
        Priority5 - Normal 3 - Low
        StatusNone Need Info
        Assigned toNone i7tiol
    2015-10-12 i7tiol Attached File- Added err_handler_stack_info.cset, #35164

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code