
Wed, 08/21/2002 - 09:26
Hi,
I always use Standard_GUID("MyDriver") to `uniquely' identify my driver, but sometimes I will call a wrong Function Driver and sometimes not. This is a hard-to-replay bug.
I think using Standard_GUID("MyDriverName") is a wrong method, we should use guidgen.exe to generate a copy and embed it into source.
I suspect that Standard_GUID(string) will use some hasing algorithm to generate a GUID.
But I haven't have a look at source code.( You know, as far as OCC's source if it is not too simple so do nothing except for calling another or just include XXX.ixx/XXX.jxx, it will be very complex and ugly to comprehend. :-(. )
I insist on my viewpoint because I have found an old post reported the same error. and in source code of OCAF, all GUID is hard-coded and accessed by fucntion, they never use such as Standard_GUID("TDataStd_Name").
SO I THINK SampleOCAF IS MISGUIDING.
Any idea about this problem?
fhchina
Wed, 08/21/2002 - 16:26
Hi,
you made a big mistake.
The string given as argument to the constructor should be a string representation of a guid ( something like "00000000-0000-0000-0000-000000000000" ), and not a "real" string.
In the code of Standard_GUID, you can see that the constructor parse the string seeking the '-' and extracting the parts.
So, with OpenCASCADE, you cannot generate some GUIDs. You can just use them.
If you are on Windows, you can use COM to generate a GUID in 2 lines ( see UuidCreate and UuidToString in the doc ).
If you are on other platform, you can check if you have libuuid installed and use uuid_generate and uuid_unparse.
HTH.
Wed, 08/21/2002 - 19:01
Thank you, Stephane.
Unfortunately, this mistake is introduced by SampleOCAF, you can read the source code of it, it use a common name string as parameter of Standard_GUID extensively, such as Standard_GUID("BoxDriver"), Standard_GUID("CutDriver"), can be seen everywhere.
fhchina
Wed, 08/21/2002 - 19:16
register a bug !
if you try :
Standard_GUID g("BoxDriver");
char* s = new char[1024];
g.ToCString(s);
cout << s << endl;
Standard_GUID g2("CutDriver");
g2.ToCString(s);
cout << s << endl;
the output is :
0000000b-0000-0000-0000-00008600000e
0000000c-0000-0000-0000-000000000000
in debug
and 0000000b-0000-0000-0000-000000000000
0000000c-0000-0000-0000-000b00000000
in release
So, I think it is a miracle it is working !
Wed, 08/21/2002 - 19:29
Hi,
There are quite a few miracles in dealing with OCC. For example, when I use Standard_GUID("HoleFeature") in release version, the application crash. But in debug version it will not. And other name, such as "ShellFeature" and even "XXXHoleFeature" will not crash, both in debug & release version.
And I have traced into Standanrd_GUID source code, I find when its couldn't find `-', it will return an unitialized big interger, then application crash.
Now I can know the answer for my previous question/post:
"Same model different file in debug & release version", %10/10 should store the GUID of driver, so each version will get incorrect driver when load file generated by other version.
fhchina
Wed, 08/21/2002 - 19:36
it doesn't crash in debug because the fields of Standard_GUID are initialized with dummy values, but in release they are not initialized ( see your compiler documentation ).
Wed, 08/21/2002 - 19:44
Sorry, forget to turn on /GZ option. I use VC 6.
fhchina
Wed, 08/21/2002 - 21:52
hi,
add your code in my app, I
got.
// Debug version
0000000b-0000-0000-0000-000000000000
0000000c-0000-0000-0000-000000000000
// Release version
0000000b-0000-0000-0000-000c0f000000
0000000c-0000-0000-0000-000b00000000
But in Debug version, turn /GZ on turn /GX off, get:
0000000b-0000-0000-0000-000c0f000000
0000000c-0000-0000-0000-000b00000000
So I think the low byte of Standard_GUID is the content of some data segment. So the
whole GUID is dependent on compiler and system. of course is wrong.
The concrete reason please have a look at my last post:
"BUG: Stanard_GUID("BoxDriver") may cause buffer overwrite".
Finaly, thank you for your inspiration. I have a lot of codes need to be modified. :-(
In fact, I have used guidgen.exe to generate and copy once. But I feel it very
labouring, and SampleOcaf use this error mode extensively. SO I...
fhchina