On Sat, Oct 25, 2014 at 12:13 AM, Glynn Clements <[email protected]> wrote: > Markus Neteler wrote: >> > r.basin map=map@Elevation prefix=o coordinates=-71.10394196,43.9865230801 >> > threshold=19005 dir=C:\\Users\\Andrea\\Basins >> > >> > I get: >> > " .... >> > v.to.rast complete. >> > All in RAM calculation... >> > Reading raster map <o_map_drainage_e>... >> > Calculating basins using vector point map... >> > Current region rows: 21612, cols: 21612 >> > ERROR: G_calloc: unable to allocate 21612 * 4 bytes of memory at io.c:41 >> ... >> >> Question: is there a way to also communicate in which *command* the >> memory allocation occurred, i.e. improve the error message? > > Why should allocation errors be different to any other error?
That's true. > For the case of scripts, it may suffice to fix run_command() etc so > that they terminate (or raise an exception) if the module returns a > non-zero exit status. If the error message is immedately followed by > "error executing <command>", it should remove most of the ambiguity. Yes, that would be a perfect solution to be implemented. >> We have 9 files called "io.c" in GRASS 7. >> Ideal would be something like: >> >> ERROR: G_calloc: unable to allocate 21612 * 4 bytes of memory at >> r.thin/io.c:41 >> >> or >> ERROR: r.thin: G_calloc: unable to allocate 21612 * 4 bytes of memory >> at r.thin/io.c:41 >> >> Not sure how to implement that in lib/gis/alloc.c > > alloc.c is the wrong place. If you want errors to be traceable, the > module name should be included for *all* errors by G_fatal_error (and > possibly others). > > Also, I wouldn't suggest using module/file.c, because that will be > inaccurate (and thus misleading) if the caller is part of a library. > > If we just want the complete filename in allocation errors, we can > modify the compiler switches to include $(RELDIR) as per the attached > patch. Similarly for use of __FILE__ in the iostream headers. Ok, I tried that patch but I don't manage to trigger it. GRASS 7.1.svn (nc_spm_08_grass7):~ > g.region rast=elevation -p res=0.01 projection: 99 (Lambert Conformal Conic) zone: 0 datum: nad83 ellipsoid: a=6378137 es=0.006694380022900787 north: 228500 south: 215000 west: 630000 east: 645000 nsres: 0.01 ewres: 0.01 rows: 1350000 cols: 1500000 cells: 2025000000000 GRASS 7.1.svn (nc_spm_08_grass7):~ > r.cost roadsmajor output=bla start_coordinates=637500.000000,221750.000000 WARNING: segment zero_fill(): Unable to write (No such file or directory) WARNING: Could not write segment file ERROR: Can not create temporary file Yet a bit unhelpful :-) It comes from lib/segment/format.c but I didn't manage to improve that. Markus _______________________________________________ grass-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/grass-dev
