Add a New Comment (Rich Markup)
Comment Type & Canned Response: None None > Multiple Canned Responses Fixed in development Crash with no stack trace Already fixed in newer version Fixed in stable Bad description Bad description and crash Bad stack trace Obsolete version Duplicate and not fixed Duplicate and needs more info Duplicate and fixed Need info and old
No complaints in a couple of weeks.
Closing as fixed.
Imho, throwing an exception in dim_vector::safe_numel is fine. We'll just need to make sure to catch that exception if we need/prefer to (like in this case).
I added a commit message to the diff in comment #1 and pushed it with jwe as the author here: https://hg.savannah.gnu.org/hgweb/octave/rev/4707df477065
Marking as ready for test.
That change looks like a step in a good direction to me. The error message is more specific and is probably more helpful for users.
Keeping the complete list of dimensions might be a lot if there are many of them. But this is an error. So, we don't need to be "pretty" in that case imho. And we could still change that later on.
i mean, it's a bit ridiculous but it would point (at least to me) out right away where my error was.
not sure about the first question, but it would make sense to limit it, but since the initial 100x1 can vary as well as the 10x2x6x... what would be the not-to-onerous way to do that. if(numchar > 80) [trim to 80 and end with ...] ?
checking how matlab's reshape yells about such things, first it doesn't allow anything other than a row vector. i was surprised ours took an array at all. then it gives:
Error using reshape Number of elements must not change. Use [] as one of the size inputs to automatically calculate the appropriate size for that dimension.
making me think it is just failing on a numel(a)==prod(b) check and reporting that.
Something like the attached change should help. With it, I see:
octave:1> a = rand (100,1); octave:2> b = randi ([0,10],10); octave:3> reshape (a, b) error: reshape: can't reshape 100x1 array to 10x2x6x1x4x8x9x1x7x0x0x0x10x6x7x0x9x3x4x9x10x9x0x10x2x2x7x4x6x1x7x9x2x8x6x9x2x8x9x4x10x1x4x7x10x7x8x0x8x5x10x10x1x0x9x5x7x2x10x10x0x1x8x6x9x10x8x7x6x9x8x6x0x0x2x1x4x2x2x8x4x6x5x10x3x6x0x5x9x10x6x3x0x7x7x5x2x1x5x6 array octave:4>
Should we handle errors in dim_vector::safe_numel in some other way than throwing std::bad_alloc?
Should we issue a different message if the number of dimensions is larger than some limit (say, 50?) since generating and displaying the exact list of dimensions is probably meaningless at that point.
(file #53536)
looking at failing code in another report (see bug #50286), it appears that a reshape was called supplying an array A as the reshape dimensions instead of size(A). this produced an error as it should, but it seems that the error slipped past input checking and instead triggered an unexpected "out of memory or dimension too large for Octave's index type", when I would think it should get caught by input checking on acceptable reshape vector size, hence making it a bit less obvious to diagnose than it should be
steps to reproduce:
a = rand(100,1); b = randi([0 10], 10); c = reshape (a, b) error: out of memory or dimension too large for Octave's index type
would have expected something like:
c = reshape (a, [10 10 10]) error: reshape: can't reshape 100x1 array to 10x10x10 array
(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)
Attach Files: Comment:
Depends on the following items: None found
Items that depend on this one: None found
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 project members can vote.
Please enter the title of George Orwell's famous dystopian book (it's a date):
Follow 5 latest changes.
Copyright © 2023 Free Software Foundation, Inc. Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved. The Levitating, Meditating, Flute-playing Gnu logo is a GNU GPL'ed image provided by the Nevrax Design Team. Source Code
Powered by Savane 3.10