Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

processSchemas crashes node process with Segmentation Fault #34

Open
simsta6 opened this issue May 8, 2023 · 6 comments
Open

processSchemas crashes node process with Segmentation Fault #34

simsta6 opened this issue May 8, 2023 · 6 comments
Labels
question Further information is requested

Comments

@simsta6
Copy link
Contributor

simsta6 commented May 8, 2023

Describe the bug
proccessSchemas crashes node process with Segmentation Fault while importing dynamic schema from source iModel when target iModel has incompatible version of that same dynamic schema.

It's possible that this bug is also reproducible with different schema importing issues.

To Reproduce

  1. Create two source iModels. Import same name dynamic schemas, but with different versions to them.
  2. Run transformation with the first iModel.
  3. Run transformation with the second iModel.
  4. Node process crashes

Expected behavior
It should throw an error

Desktop (please complete the applicable information):

  • OS: windows
  • @itwin/imodel-transformer Version: 0.1.3
  • iTwin.js Version: 3.6.1

Additional context
Add any other context about the problem here.

EC Schemas for test cases:

        <?xml version="1.0" encoding="UTF-8"?>
        <ECSchema schemaName="RevitDynamic" alias="RVT13469" version="01.07.00" displayLabel="Revit" xmlns="http://www.bentley.com/schemas/Bentley.ECXML.3.2">
            <ECCustomAttributes>
                <DynamicSchema xmlns="CoreCustomAttributes.01.00.03"/>
            </ECCustomAttributes>
        </ECSchema>
        <?xml version="1.0" encoding="UTF-8"?>
        <ECSchema schemaName="RevitDynamic" alias="RVT1641" version="01.05.02" displayLabel="Revit" xmlns="http://www.bentley.com/schemas/Bentley.ECXML.3.2">
            <ECCustomAttributes>
                <DynamicSchema xmlns="CoreCustomAttributes.01.00.03"/>
            </ECCustomAttributes>
        </ECSchema>
@MichaelBelousov
Copy link
Contributor

MichaelBelousov commented Aug 7, 2023

I feel like your description and reproduction steps don't match... Are you saying it crashes "when reusing a single transformer instance on a second source" or "when transforming between any source and target with a same-name dynamic schema"?

@MichaelBelousov
Copy link
Contributor

MichaelBelousov commented Aug 7, 2023

@simsta6 I have created this test and it does not reproduce. Could you point out where I'm deviating from your description? (the branch is here if you'd like to fork/edit it)

it.only("handle same name dynamic schemas", async function () {
  const makeDynamicSchema = (version: string) => `<?xml version="1.0" encoding="UTF-8"?>
      <ECSchema schemaName="Dynamic" alias="d1" version="${version}" displayLabel="dyn" xmlns="http://www.bentley.com/schemas/Bentley.ECXML.3.2">
          <ECCustomAttributes>
              <DynamicSchema xmlns="CoreCustomAttributes.01.00.03"/>
          </ECCustomAttributes>
      </ECSchema>
  `;

  /* eslint-disable @typescript-eslint/naming-convention */
  const dynamicSchema1_7_0 = makeDynamicSchema("01.07.00");
  const dynamicSchema1_5_2 = makeDynamicSchema("01.05.02");
  /* eslint-enable @typescript-eslint/naming-convention */

  const sourceDbFile: string = IModelTransformerTestUtils.prepareOutputFile("IModelTransformer", "DynSchemas-Source.bim");
  const sourceDb = SnapshotDb.createEmpty(sourceDbFile, { rootSubject: { name: "DynSchemaSource" } });
  await sourceDb.importSchemaStrings([dynamicSchema1_7_0]);
  sourceDb.saveChanges();

  const targetDbFile: string = IModelTransformerTestUtils.prepareOutputFile("IModelTransformer", "DynSchemas-Target.bim");
  const targetDb = SnapshotDb.createEmpty(targetDbFile, { rootSubject: { name: "DynSchemasTarget" } });
  await targetDb.importSchemaStrings([dynamicSchema1_5_2]);
  targetDb.saveChanges();

  const transformer = new IModelTransformer(sourceDb, targetDb);
  // expect this to not reject, adding chai as promised makes the error less readable
  await transformer.processSchemas();

  expect(targetDb.querySchemaVersion("Dynamic")).to.equal("1.7.0");

  // clean up
  transformer.dispose();
  sourceDb.close();
  targetDb.close();
});

@MichaelBelousov
Copy link
Contributor

possibly fixed by iTwin/imodel-native#404

@MichaelBelousov
Copy link
Contributor

will update once iTwin/imodel-native#404 is released in a patch

@MichaelBelousov
Copy link
Contributor

was release as 4.1.1 (iirc).
@simsta6 is it possible to test this?

@simsta6
Copy link
Contributor Author

simsta6 commented Sep 7, 2023

@MichaelBelousov it will take some time. I will get back to you when I will test it out

@nick4598 nick4598 added the question Further information is requested label Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants