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

Memory leak in dwg2dxf #18

Open
ghost opened this issue Oct 21, 2020 · 2 comments
Open

Memory leak in dwg2dxf #18

ghost opened this issue Oct 21, 2020 · 2 comments
Assignees

Comments

@ghost
Copy link

ghost commented Oct 21, 2020

When converting the file Ceco.NET-Architecture-Tm-271.dwg obtained from here
with dwg2dxf 1.0.1
it consumes memory at a rate of 1GB every 5 seconds or so and appears to have no limit (I killed it after 40GB)

@Akaame
Copy link

Akaame commented Jan 10, 2021

This is not a memory leak.

I run the code in debug mode and the line here reports

spline->ncontrol = buf->getBitLong();

470484544 ncontrol for a spline in the hatch. Considering this creates a shared pointer to a DRW_Coord object spline's control list would hog like 13 GBs of memory. But the problem obviously is not the memory here nor the file itself (I do not think it is corrupted or anything). The convertor does not have this problem for CADs without hatch type object. The section (L1900 to L 1918 in the file above) that adds the spline must be revisited.

Other CAD files from Villa Savoye suffer from the same problem.

@Akaame
Copy link

Akaame commented Jan 10, 2021

The issue turned out be a parsing error as I suspected. I used the DWG file spec found here to make a comparison with the actual code and there appears to be two mistakes in both this branch and to the mainline code in the SourceForge. Below is the simple patch file created by git diff of the fix.

libdxfrw_18.patch.zip

Steps:

  1. Get the mainline codebase
  2. Add the following files to the new code base from this fork: libdxfrw.dox, CMakeLists.txt, src/main_doc.h, dwg2dxf/CMakeLists.txt
  3. Apply the patch
  4. Run cmake and make in build as stated in README.md of this branch
  5. build/dwg2dxf/dwg2dxf path/to/dwg path/to/output_dxf

Cheers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants