Thu 26 Jun 2014 04:57:56 PM UTC, comment #12:
Good. Closing report a second, hopefully final, time.
|
Thu 26 Jun 2014 04:43:59 PM UTC, comment #11:
Hmmm, that's right, silly of me to forget the mexw32 instead of mex the first time, here's the result with the file renamed with the mexw32 extension (it is the extension on this machine):
>> exist ('mexfunction', 'file')
ans =
3.0000e+000
>> exist ('mexfunction.mexw32', 'file')
ans =
3.0000e+000
So Matlab doesn't know any better either.
|
Thu 26 Jun 2014 04:38:09 PM UTC, comment #10:
I checked in a changeset that I believe fixes the problem with bad symbol table lookups (http://hg.savannah.gnu.org/hgweb/octave/rev/a0fd65914811). I'll wait for Richard's verification results before closing this report again.
|
Thu 26 Jun 2014 04:36:46 PM UTC, comment #9:
The problem is this line in symbol_exist in variables.cc:
It might be possible to use a try/catch or unwind_protect around this piece of code. I just used try/catch and it seemed to work.
@Richard: Could you run mexext() and see what Matlab returns? I think for your case it will return 'mexw32'. If this is the case, then I would like to rename the "Hello World" file to "mexfunction.mexw32" and then re-run
According to Matlab's own documentation, they shouldn't be parsing the file, only looking at the extension to determine whether to return 2 or 3.
|
Thu 26 Jun 2014 03:58:14 PM UTC, comment #8:
I'm re-opening the bug. There is a deep problem when the file has a name that looks like a mex file, but is not in fact a mex file. The example of a text file with "Hello World" in it shows this.
Under the development branch with all of the latest changes to exist, I get
This is related to bug #36067. The problem is that in checking for a built-in Octave looks in the symbol table for the name. If it doesn't find it in the symbol table, but does find what looks like a possible mex file, it tries to load it. This generates the exception. It would be nice if there were a way to simply query the symbol table, but functions would not be loaded until they were asked for, i.e., someone typed the function name on the command line and tried to invoke it.
|
Thu 26 Jun 2014 02:01:01 PM UTC, comment #7:
Just to update, on ML I ge the following result
mexfunction.mex
---------------
Hello World
---------------
mexfunction2.mex
---------------
#include "mex.h"
/* the gateway function */
void mexFunction( int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[])
{
plhs[0] = mxCreateDoubleScalar(1.0);
}
---------------
>> exist ('mexfunction.mex', 'file')
ans =
2.0000e+000
>> exist ('mexfunction', 'file')
ans =
0.0000e+000
>> exist ('mexfunction2', 'file')
ans =
3.0000e+000
>> exist ('mexfunction2.mexw32', 'file')
ans =
3.0000e+000
|
Wed 25 Jun 2014 09:18:13 PM UTC, comment #6:
Ok, good. Then assuming it is indeed 3 for both cases in Matlab, this is now fixed with Rik's change.
|
Wed 25 Jun 2014 09:12:49 PM UTC, comment #5:
No ,i was being silly, that result was for octave (but i guess you could have done this yourself).
I'll try the same test in ML tomorrow, but the help for 'exist' does also imply it should be 3 in both cases in Octave too.
|
Wed 25 Jun 2014 09:04:43 PM UTC, comment #4:
I made the behavior Matlab compatible in this changeset on the development branch (http://hg.savannah.gnu.org/hgweb/octave/rev/a1dde4d4c45c).
|
Wed 25 Jun 2014 08:41:43 PM UTC, comment #3:
I'm confused, can you please clarify? You originally said Matlab would return 3 for both exist('foo') and exist('foo.mex'), but in comment #2 you have
> >> exist ('mexfunction2')
>
> ans = 3
>
> >> exist ('mexfunction2.mex')
>
> ans = 2
where mexfunction2 is an actual compiled mex file. Was this from Matlab, is this the actual behavior? If so, I'm failing to see what the bug is.
|
Wed 25 Jun 2014 08:14:26 PM UTC, comment #2:
Apparently not, I created a text file containing just "Hello World" in the current irectory and got
>> exist ('mexfunction')
ans = 3
>> exist ('mexfunction.mex')
ans = 2
I then made a trivial mex function:
-----
#include "mex.h"
/* the gateway function */
void mexFunction( int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[])
{
plhs[0] = mxCreateDoubleScalar(1.0);
}
-----
and get
>> mexfunction2
ans = 1
>> exist ('mexfunction2')
ans = 3
>> exist ('mexfunction2.mex')
ans = 2
|
Wed 25 Jun 2014 05:21:33 PM UTC, comment #1:
Does it matter if mexfunction.mex is actually a mex file?
Could you create a text file with "Hello World" in it and name it mexfunction.mex and then repeat the two exist calls in Matlab?
|
Wed 25 Jun 2014 04:20:20 PM UTC, original submission:
As in the title, the exist function returns 3 for 'mexfunction', but 2 for 'mexfunction.mex'. Matlab returns 3 for both.
This is using hg id 47d4b680d0e0 @
|