MantisBT - Community
View Issue Details
0027187Community[OCCT] OCCT:Application Frameworkpublic2016-02-19 08:592017-09-29 16:29
Vico Liang 
bugmaster 
normalminor 
closedfixed 
WindowsVC++ 201364 bit
[OCCT] 6.9.1 
[OCCT] 7.2.0[OCCT] 7.2.0 
bugs caf bug27187
0027187: XmlMFunction_ScopeDriver fail to read and write function label including 0 tag in label path.
XmlMFunction_ScopeDriver will explicitely escape the 0 tag in the label entry path e.g. "0:1:4:9999:0:1:4:2001:4:2001:4:1:4:1001:4:1001". It thought that 0 tag should just occur in the root Label. But in practice, it should not have such restriction. User might want to set any integer tag in application. As a data driver, it should not alter the users attampt.

It's lucky that BinMFunction_ScopeDriver works well.
bugs/caf/bug27187
No tags attached.
? XML_DRIVER_ERROR.rbsx (5,797) 2016-02-19 08:59
https://tracker.dev.opencascade.org/
Issue History
2016-02-19 08:59Vico LiangNew Issue
2016-02-19 08:59Vico LiangAssigned To => mpv
2016-02-19 08:59Vico LiangFile Added: XML_DRIVER_ERROR.rbsx
2016-02-26 18:08mpvNote Added: 0051183
2016-05-11 03:39Vico LiangNote Added: 0053976
2016-10-25 16:06mpvTarget Version7.1.0 => 7.2.0
2017-05-22 14:42mpvAssigned Tompv => szy
2017-05-25 17:01szyAssigned Toszy => vro
2017-05-25 17:09szyNote Added: 0066599
2017-05-26 07:00vroNote Added: 0066619
2017-05-26 07:00vroAssigned Tovro => mpv
2017-05-26 09:42szyTarget Version7.2.0 => Unscheduled
2017-05-26 11:10mpvNote Added: 0066626
2017-05-26 11:10mpvStatusnew => feedback
2017-05-26 11:11mpvAssigned Tompv => Vico Liang
2017-05-26 11:25szyNote Added: 0066632
2017-05-27 01:48Vico LiangNote Added: 0066676
2017-05-27 01:50Vico LiangNote Added: 0066677
2017-05-27 01:52Vico LiangStatusfeedback => assigned
2017-05-27 01:52Vico LiangAssigned ToVico Liang => mpv
2017-05-27 01:52Vico LiangStatusassigned => feedback
2017-05-27 11:18Vico LiangStatusfeedback => assigned
2017-05-28 06:06Vico LiangNote Added: 0066681
2017-05-29 12:18gitNote Added: 0066712
2017-05-29 12:21mpvNote Added: 0066713
2017-05-29 12:21mpvAssigned Tompv => vro
2017-05-29 12:21mpvStatusassigned => resolved
2017-05-29 12:21mpvSteps to Reproduce Updatedbug_revision_view_page.php?rev_id=16815#r16815
2017-05-29 12:47vroAssigned Tovro => mpv
2017-05-29 12:47vroStatusresolved => reviewed
2017-05-29 12:52mpvAssigned Tompv => bugmaster
2017-05-29 13:37apvAssigned Tobugmaster => apv
2017-05-30 11:04apvTest case number => bugs caf bug27187
2017-05-30 11:09apvNote Added: 0066853
2017-05-30 11:09apvAssigned Toapv => bugmaster
2017-05-30 11:09apvStatusreviewed => tested
2017-05-30 11:10apvNote Added: 0066854
2017-06-01 09:58bugmasterTarget VersionUnscheduled => 7.2.0
2017-06-02 10:31bugmasterNote Added: 0066975
2017-06-02 10:31bugmasterStatustested => verified
2017-06-02 10:31bugmasterResolutionopen => fixed
2017-06-02 10:45gitNote Added: 0066996
2017-08-14 16:05abvChangeset attached => occt master ec2039e9
2017-09-29 16:17aivFixed in Version => 7.2.0
2017-09-29 16:29aivStatusverified => closed

Notes
(0051183)
mpv   
2016-02-26 18:08   
Yes, I agree that this condition is missed in the source code and documentation, but supposed and used by developers. We have plans to add information that not-root label tag must be greater than zero in the documentation and produce and exception in code for such invalid cases.
(0053976)
Vico Liang   
2016-05-11 03:39   
Dear mpv,

I can't agree that not-root label tag must be greater than zero in the documentation. I think zero tag should be reasonable in application, e.g. if user want to copy other document label tree completely to a child label of my document, this case would not be supported.

I see binary format will support any tag value, it's correct i think. This logic should not be done in document save and restore driver, if you think zero tag is not supported, it's better do it in label tag assign operator.
(0066599)
szy   
2017-05-25 17:09   
Vlad,
Check, please if the mentioned limitation exists in XmlMFunction_ScopeDriver (?).
I think that Binary and Xml drivers should be synchronized.
Document itself has no such limitation's.
(0066619)
vro   
2017-05-26 07:00   
TFunction_Scope writes labels as a long string (the labels are separated by spaces). So, no special TAG is used for XML and it shouldn't cause any known problems.
(0066626)
mpv   
2017-05-26 11:10   
The store/restore documnent with zero-tagged labels are supported correctly by XML drivers. No XmlMFunction_ScopeDriver were detected in the following test-case:

NewDocument D XmlOcaf
Label D 0:1:4:9999:0:1:4:2001:4:2001:4:1:4:1001:4:1001
SetInteger D 0:1:4:9999:0:1:4:2001:4:2001:4:1:4:1001:4:1001 7
SaveAs D file.xml
Close D
Open file.xml D
GetInteger D 0:1:4:9999:0:1:4:2001:4:2001:4:1:4:1001:4:1001
-> 7

So, it work fine.

The attached file is already broken, but stored in custom format "RBKernelRBSXml", so, we don't know how to reproduce this test case.

Vico, could you provide a test case that allows to reproduce the problem in OCCT, not in your specific application? This will approve that the problem is in OCCT, not in specific development.
(0066632)
szy   
2017-05-26 11:25   
Dear Vico,
We didn't findd the specified limitation neither in Document driver neither in ScopeDriver.
Also we can't reproduce the issue using the provided by you description.
I just can guess that the real problem may be located inside your specific code.
In any case when you report the issue you should take care to make it reproducible in Open CasCade environment, for example in DrawHarness.
In case if you are not friendly with Draw environment you can use alternative way providing a standalone sample (including project files to build it) allowing to reproduce your case. If it is difficult for you we can offer you our professional support services, for example HelpDesk Query (https://www.opencascade.com/content/helpdesk-query [^]).
Please follow this way in case if you are interested in resolution of the reported problem.
(0066676)
Vico Liang   
2017-05-27 01:48   
Standard_Boolean XmlObjMgt::GetTagEntryString
                                        (const XmlObjMgt_DOMString& theSource,
                                         TCollection_AsciiString& theTagEntry)
{
  // Check the prefix
  const size_t aPrefixSize = sizeof(aRefPrefix) - 1;
  const char * aSource = theSource.GetString();
  if (strncmp (aSource, aRefPrefix, aPrefixSize))
    return Standard_False;

  // Beging aTagEntry string
  char * aTagEntry =
    (char *) Standard::Allocate (strlen(aSource)/2); // quite enough to hold it
  char * aTagEntryPtr = aTagEntry + 1;
  * aTagEntry = '0';
  aSource += aPrefixSize;

  // Find all individual tags in a loop
  const size_t anElem1Size = sizeof(aRefElem1) - 1;
  const size_t anElem2Size = sizeof(aRefElem2) - 1;
  while (aSource[0] != '\0') {
    // Check the first part of individual tag: "/label[@tag="
    if (strncmp (aSource, aRefElem1, anElem1Size))
      return Standard_False;
    aSource += anElem1Size;
    const char aQuote = aSource[0];
    if (aQuote != '\'' && aQuote != '\"')
      return Standard_False;

    // Check the integer value of the tag
    errno = 0;
    char * aPtr;
    long aTagValue = strtol (&aSource[1], &aPtr, 10);
    if (aTagValue <= 0 || aPtr[0] != aQuote ||
        errno == ERANGE || errno == EINVAL)
      return Standard_False;
(0066677)
Vico Liang   
2017-05-27 01:50   
Dear szy,

Sorry that it difficult for me to provide test case to reproduce this issue. It's fortunately that i find the issue from the source code, please see the previous code snippet. the last line

if (aTagValue <= 0 || aPtr[0] != aQuote ||
         errno == ERANGE || errno == EINVAL)
       return Standard_False;
(0066681)
Vico Liang   
2017-05-28 06:06   
This can be fixed by remove conditional filter "aTagValue <= 0" from if statement
(0066712)
git   
2017-05-29 12:18   
Branch CR27187 has been created by mpv.

SHA-1: e66dacf1c84206cd95722057aeedb36e973c2fea


Detailed log of new commits:

Author: mpv
Date: Mon May 29 12:16:56 2017 +0300

    0028714: XmlMFunction_ScopeDriver fail to read and write function label including 0 tag in label path.
    
    Reproduced on TDF_Reference attribute that refers to label with zero-tags entry. Make checking of saved/retrieved tags in XML format pass zero-tags as correct.
(0066713)
mpv   
2017-05-29 12:21   
The problem is reproduced on TDF_Reference attribute referenced on zer-tagged label.

Fixed. Please, review.
(0066853)
apv   
2017-05-30 11:09   
Dear BugMaster,

Branch CR27187 from occt git-repository (and master from products git-repository) was compiled on Linux, MacOS and Windows platforms and tested.
SHA-1: e66dacf1c84206cd95722057aeedb36e973c2fea

Number of compiler warnings:
occt component:
   Linux: 0 (0 on master)
   Windows: 0 (0 on master)
   MasOS: 0 (0 on master)
products component:
   Linux: 64
   Windows: 0
   MacOS: 1201

Regressions/Differences:
Not detected

Testing cases:
bugs caf bug27187 - OK
http://occt-tests/CR27187-master-OCCT/Debian70-64/bugs/caf/bug27187.html [^]
http://occt-tests/CR27187-master-OCCT/Windows-64-VC10/bugs/caf/bug27187.html [^]

Testing on Linux:
Total MEMORY difference: 91578829 / 91842464 [-0.29%]
Total CPU difference: 18590.12000000032 / 19347.320000000098 [-3.91%]

Testing on Windows:
Total MEMORY difference: 58498744 / 58497831 [+0.00%]
Total CPU difference: 17325.50226019865 / 17520.28510879866 [-1.11%]
(0066854)
apv   
2017-05-30 11:10   
Dear BugMaster,

Please integrate branch CR27187 into the occt git-repository master.
(0066975)
bugmaster   
2017-06-02 10:31   
Fix has been integrated into master of occt-products repository
(0066996)
git   
2017-06-02 10:45   
Branch CR27187 has been deleted by inv.

SHA-1: e66dacf1c84206cd95722057aeedb36e973c2fea