MapWindow / MapWindow5

MW5 is a desktop GIS which is extendable using the plug-in architecture. It is using the MapWinGIS mapping control and is created from scratch in 2015 using new technologies like MEF and Dependency Injection making it small in size, robust and fast.
288 stars 100 forks source link

WM5 Crash when I cut shape feature times #139

Closed ningfc closed 2 years ago

ningfc commented 2 years ago

I try to cut shapes multiple times, and crash happend. I'm try to debugging and found the position in MapWinGIS component TableRow::~TableRow(), app crashed with call function VariantClear. But the crash not happened when run MapWinGIS deom application (MapWindowLite.exe) and do the same thing.

And crash no happened when I comments function VariantClear in TableRow::~TableRow().

image

And follow is last few lines of debug output window. 线程 0x1898 已退出,返回值为 0 (0x0)。 OCX: MAP PROJECTION SET: +proj=longlat +datum=WGS84 +no_defs 0x7546EA32 处(位于 MapWindow.exe 中)引发的异常: Microsoft C++ 异常: EEFileLoadException,位于内存位置 0x0059C0B4 处。 0x7546EA32 处(位于 MapWindow.exe 中)引发的异常: Microsoft C++ 异常: [rethrow],位于内存位置 0x00000000 处。 0x7546EA32 处(位于 MapWindow.exe 中)引发的异常: Microsoft C++ 异常: [rethrow],位于内存位置 0x00000000 处。 0x7546EA32 (KernelBase.dll)处(位于 MapWindow.exe 中)引发的异常: 0xE0434352 (参数: 0x80070002, 0x00000000, 0x00000000, 0x00000000, 0x73400000)。

Critical error detected c0000374

MapWindow.exe 已触发了一个断点。

pmeems commented 2 years ago

Which version of MWGis are you using? Can you add the code you're using that does the cutting, so we can try to reproduce it?

ningfc commented 2 years ago

Which version of MWGis are you using? Can you add the code you're using that does the cutting, so we can try to reproduce it?

MapWindow v5.6.3 with MapWinGIS v5.2.4

pmeems commented 2 years ago

OK. So you are using MW5 to cut the shapefile. Do you experience this error with every shapefile or just with one? And are you cutting the same shape every time or different shapes in the same shapefile? What kind of shapefile are you cutting: line, polygon? Can you add the shapefile so we can use it for our tests?

ningfc commented 2 years ago

OK. So you are using MW5 to cut the shapefile. Do you experience this error with every shapefile or just with one? And are you cutting the same shape every time or different shapes in the same shapefile? What kind of shapefile are you cutting: line, polygon? Can you add the shapefile so we can use it for our tests?

The shape file type I used is a polyline. and I tried a lot of times in different shapes, and different shape files. Shape file With UTF8 encoding. Shape file I used

ningfc commented 2 years ago

OK. So you are using MW5 to cut the shapefile. Do you experience this error with every shapefile or just with one? And are you cutting the same shape every time or different shapes in the same shapefile? What kind of shapefile are you cutting: line, polygon? Can you add the shapefile so we can use it for our tests?

The shape file type I used is a polyline. and I tried a lot of times in different shapes, and different shape files. Shape file With UTF8 encoding. Shape file I used

When I Add This line to ignore VT_BSTR. No crash happen. Perhaps this related with BSTR type. image

jerryfaust commented 2 years ago

Hello @ningfc, and thank you for the detail you have provided.

I don't think there is anything wrong with the code here. Instead, I think this may related to another issue that I just recently resolved. If you consider this issue in the MapWinGIS Discourse, you will see that the current release is not properly handling Shapefiles that use the UTF-8 encoding. This could account for intermittent errors when trying to clear a BSTR variant, since it may not know the correct length, and is therefore trying to release memory that it doesn't own.

I have not yet submitted my code changes because, although I have now accounted for UTF-8 encoding, I have not yet accounted for Shapefiles that have other encodings. Even so, I could perhaps submit my changes so that, if you are willing, you could get my changes, rebuild the OCX, and see if the error still occurs. Would you be willing to do that?

Thank you, and Regards, Jerry.

ningfc commented 2 years ago

Hello @ningfc, and thank you for the detail you have provided.

I don't think there is anything wrong with the code here. Instead, I think this may related to another issue that I just recently resolved. If you consider this issue in the MapWinGIS Discourse, you will see that the current release is not properly handling Shapefiles that use the UTF-8 encoding. This could account for intermittent errors when trying to clear a BSTR variant, since it may not know the correct length, and is therefore trying to release memory that it doesn't own.

I have not yet submitted my code changes because, although I have now accounted for UTF-8 encoding, I have not yet accounted for Shapefiles that have other encodings. Even so, I could perhaps submit my changes so that, if you are willing, you could get my changes, rebuild the OCX, and see if the error still occurs. Would you be willing to do that?

Thank you, and Regards,

Jerry.

Yes I will,It's my pleasure for test your new changes.

jerryfaust commented 2 years ago

Hello again.

Code has been checked in to the 'develop' branch to (hopefully) handle issues related to Shapefiles that use the UTF-8 encoding as specified in the Code Page file (.CPG). It will be interesting to know if this resolves your problem as well.

Thank you, and Kind Regards, Jerry.

ningfc commented 2 years ago

Hello again.

Code has been checked in to the 'develop' branch to (hopefully) handle issues related to Shapefiles that use the UTF-8 encoding as specified in the Code Page file (.CPG). It will be interesting to know if this resolves your problem as well.

Thank you, and Kind Regards, Jerry.

I tested your Code, It works fine, saving Shapefile that use the UTF-8 encoding is OK. My problem may cause by myself code for change variant type to VT_BSTR use VariantChangeType, So sorry. And I just resolved it. It is becouse I use VariantChangeType to a local param, but not a pointer or reference.

Thank you for your patience and help! Regards to you.