Double free memory on Linux

Hello Aspose team,

I encountered double free memory or corruption when converting multiple Excel files to image (JPEG) on Linux concurrently. It happened randomly so it’s quite hard to reproduce. I also attached the backtrace on error for more information.

Environment: Aspose.Cells 22.3, CentOS 7, .NET 6.0

Code:
var options = new ImageOrPrintOptions
{
OnePagePerSheet = false,
ImageType = ImageType.Jpeg,
PrintingPage = PrintingPageType.Default
};

foreach(var sheet in workbook.Worksheets)
{
var sr = new SheetRender(sheet, options);
for(int j = 0; j < sr.PageCount; j++)
{
var imgOut = $“outfile_{j}.jpg”
sr.ToImage(j, imgOut);
}
}

Backtrace on error:
aspose_cells_issue.png (5.3 KB)

@dunghnguyen,

It is hard to evaluate your issue based on your given details and artifacts. Also, your issue occurred randomly as you pointed out. We need a simulation project with template file(s) to reproduce the issue on our end. So, please share with us a simulation project with sample files to reproduce the issue. We will check your issue soon.

@Amjad_Sahi

Please find the test program and samples attached. Then run it a few times until the issue happens. :grinning:

cell_test.zip (2.4 KB)
xlsx_sample.zip (596.0 KB)

Example output:
cells__1.png (27.9 KB)

Hi @dunghnguyen
I can run your project, and test dozens of times, but the problem didn’t happen.
My test Environment is Ubuntu20.04, net6, memory 2GB.

I noticed that the 4 test files you provided had previously solved a problem caused by a special character, but the next version will take effect.

Can you remove the special characters in 4 files, so that all the pictures generate normally, try test in your environment, whether there is any “coredump” exception found?

Hi @leoluo.
I try with another set of samples and can reproduce the problem. Below is more details about my test environment and samples, and core dump attached.

$ uname -a
Linux localhost.localdomain 3.10.0-1160.59.1.el7.x86_64 #1 SMP Wed Feb 23 16:47:03 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

$ dotnet --info
.NET SDK (reflecting any global.json):
 Version:   6.0.201
 Commit:    ef40e6aa06

Runtime Environment:
 OS Name:     centos
 OS Version:  7
 OS Platform: Linux
 RID:         centos.7-x64
 Base Path:   /usr/share/dotnet/sdk/6.0.201/

Host (useful for support):
  Version: 6.0.3
  Commit:  c24d9a9c91

.NET SDKs installed:
  3.1.417 [/usr/share/dotnet/sdk]
  6.0.201 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.23 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.15 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.3 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.23 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.15 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.3 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

$ yum list installed | grep gdi
libgdiplus0.x86_64                    6.0.5-0.xamarin.1.epel7    @mono-centos7-stable

$ yum deplist libgdiplus0.x86_64
package: libgdiplus0.x86_64 6.0.5-0.xamarin.1.epel7
  dependency: /sbin/ldconfig
   provider: glibc.x86_64 2.17-325.el7_9
   provider: glibc.i686 2.17-325.el7_9
  dependency: libX11.so.6()(64bit)
   provider: libX11.x86_64 1.6.7-4.el7_9
  dependency: libc.so.6(GLIBC_2.14)(64bit)
   provider: glibc.x86_64 2.17-325.el7_9
  dependency: libcairo.so.2()(64bit)
   provider: cairo.x86_64 1.15.12-4.el7
  dependency: libexif.so.12()(64bit)
   provider: libexif.x86_64 0.6.22-2.el7_9
  dependency: libfontconfig.so.1()(64bit)
   provider: fontconfig.x86_64 2.13.0-4.3.el7
  dependency: libfreetype.so.6()(64bit)
   provider: freetype.x86_64 2.8-14.el7_9.1
  dependency: libgif.so.4()(64bit)
   provider: giflib.x86_64 4.1.6-9.el7
  dependency: libglib-2.0.so.0()(64bit)
   provider: glib2.x86_64 2.56.1-9.el7_9
  dependency: libjpeg.so.62()(64bit)
   provider: libjpeg-turbo.x86_64 1.2.90-8.el7
  dependency: libjpeg.so.62(LIBJPEG_6.2)(64bit)
   provider: libjpeg-turbo.x86_64 1.2.90-8.el7
  dependency: libm.so.6()(64bit)
   provider: glibc.x86_64 2.17-325.el7_9
  dependency: libm.so.6(GLIBC_2.2.5)(64bit)
   provider: glibc.x86_64 2.17-325.el7_9
  dependency: libpng15.so.15()(64bit)
   provider: libpng.x86_64 2:1.5.13-8.el7
  dependency: libpng15.so.15(PNG15_0)(64bit)
   provider: libpng.x86_64 2:1.5.13-8.el7
  dependency: libpthread.so.0()(64bit)
   provider: glibc.x86_64 2.17-325.el7_9
  dependency: libpthread.so.0(GLIBC_2.2.5)(64bit)
   provider: glibc.x86_64 2.17-325.el7_9
  dependency: libtiff.so.5()(64bit)
   provider: libtiff.x86_64 4.0.3-35.el7
  dependency: libtiff.so.5(LIBTIFF_4.0)(64bit)
   provider: libtiff.x86_64 4.0.3-35.el7
  dependency: libz.so.1()(64bit)
   provider: zlib.x86_64 1.2.7-19.el7_9
  dependency: rtld(GNU_HASH)
   provider: glibc.x86_64 2.17-325.el7_9
   provider: glibc.i686 2.17-325.el7_9

Sample: sample__2.zip (679.2 KB)
Coredump: Encl: Send files to anyone easily and securely (too large to attach, expires in 7 days)

Many thanks!

Hi @dunghnguyen
Please check my libgdiplus and environment:

[asposecells@aspose ~]$ dotnet --info
.NET SDK (reflecting any global.json):
Version: 6.0.101
Commit: ef49f6213a

Runtime Environment:
OS Name: centos
OS Version: 7
OS Platform: Linux
RID: centos.7-x64
Base Path: /usr/share/dotnet/sdk/6.0.101/

Host (useful for support):
Version: 6.0.1
Commit: 3a25a7f1cc

.NET SDKs installed:
3.1.415 [/usr/share/dotnet/sdk]
6.0.101 [/usr/share/dotnet/sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.21 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.1 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.21 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.1 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET runtimes or SDKs:
.NET Downloads (Linux, macOS, and Windows)
[asposecells@aspose ~]$ yum list installed | grep gdi
Repository packages-microsoft-com-prod is listed more than once in the configuration
libgdiplus.x86_64 2.10-10.el7 @epel

I notice that your version is:
libgdiplus0.x86_64 6.0.5-0.xamarin.1.epel7

Mine is:
libgdiplus.x86_64 2.10-10.el7

I’ve looked up some information, and different libgdiplus versions really can lead to different results:

If you can confirm how you installed this libgdiplus version, my install command is:

sudo yum install libgdiplus

Hi @leoluo.

I followed the instruction here to install libgdiplus.

Thank you.

@dunghnguyen,

Thanks for your confirmation.

We have logged an investigation ticket with an id “CELLSNETCORE-379” for your issue. We will evaluate and look into the details of the problem.

Once we have an update on it, we will let you know.

1 Like

Hi @amjad.sahi, is there any update on this?

@dunghnguyen
No updates on your issue. Once we have any new information, we will share it with you. We will get back to you soon.

Hi @dunghnguyen
I noticed that in the error message you used libgdiplus, which I think you used aspose.Cells which should be dependent on the graphics library “System.Drawing.common”.
Because Microsoft claims “system.drawing.common” is no longer supported on Linux:

Since the graphics library is no longer supported, it may have some sorts of unpredictable, random problems under Linux.

Based on this statement, we developed a new aspose.Cells version, depending on the graphics library skiasharp. (At the time you encountered this problem, this version had not yet been released. Now, it’s stable for use.)

Please refer to the documentation below to use SKIASHARP as a graphics library in Linux to solve this problem.