xs2svg on a big figure crashes scilab master
Reported by Antoine Monmayrant
Originally assigned to Calixte DENIZET
The recent change in the way graphics are exported has introduced new bugs.
When trying to export a large figure in svg, the last scilab master crashes whereas scilab XXX just display an errror message.
Here is a sample script to trigger the bug:
//////////////////////////////////
//You might have to increase n to trigger the bug
n=1000;
M=rand(n,n);
h=scf();
grayplot(1:n,1:n,M);
xs2svg(h,"kaboom.svg");
//////////////////////////////////
# With scilab 5.4-alpha, this script generates an error:
xs2svg(h,"kaboom.svg");
!--error 999
xs2svg : Unable to create export file, figure is too big.
at line 7 of exec file called by :
./bug_export.sce', -1
# With the last master, it crashes:
Info: XInitThreads() called for concurrent Thread support
terminate called after throwing an instance of 'GiwsException::JniCallMethodException'
what(): Exception when calling Java method : Direct buffer memory
at java.nio.Bits.reserveMemory(Unknown Source)
at java.nio.DirectByteBuffer.<init>(Unknown Source)
at java.nio.ByteBuffer.allocateDirect(Unknown Source)
at com.jogamp.common.nio.Buffers.newDirectByteBuffer(Buffers.java:69)
at com.jogamp.common.nio.Buffers.newDirectFloatBuffer(Buffers.java:111)
at org.scilab.modules.renderer.JoGLView.util.BufferAllocation.newFloatBuffer(Unknown Source)
at org.scilab.modules.renderer.JoGLView.DataManager.fillColorBuffer(Unknown Source)
at org.scilab.modules.renderer.JoGLView.DataManager.getColorBuffer(Unknown Source)
at org.scilab.modules.renderer.JoGLView.DrawerVisitor.visit(Unknown Source)
at org.scilab.modules.graphic_objects.imageplot.Grayplot.accept(Unknown Source)
at org.scilab.modules.renderer.JoGLView.DrawerVisitor.askAcceptVisitor(Unknown Source)
at org.scilab.modules.renderer.JoGLView.axes.AxesDrawer.draw(Unknown Source)
at org.scilab.modules.renderer.JoGLView.DrawerVisitor.visit(Unknown Source)
at org.scilab.modules.graphic_objects.axes.Axes.accept(Unknown Source)
at org.scilab.modules.renderer.JoGLView.DrawerVisitor.askAcceptVisitor(Unknown Source)
at org.scilab.modules.renderer.JoGLView.DrawerVisitor.visit(Unknown Source)
at org.scilab.modules.graphic_objects.figure.Figure.accept(Unknown Source)
at org.scilab.modules.renderer.JoGLView.DrawerVisitor.draw(Unknown Source)
at org.scilab.forge.scirenderer.implementation.g2d.G2DCanvas.draw(Unknown Source)
at org.scilab.forge.scirenderer.implementation.g2d.G2DCanvas.redraw(Unknown Source)
at org.scilab.modules.graphic_export.Export.exportVectorial(Unknown Source)
at org.scilab.modules.graphic_export.Export.exportVectorial(Unknown Source)
at org.scilab.modules.graphic_export.Export.export(Unknown Source)
at org.scilab.modules.graphic_export.FileExporter.fileExport(Unknown Source)
Direct buffer memory
at java.nio.Bits.reserveMemory(Unknown Source)
at java.nio.DirectByteBuffer.<init>(Unknown Source)
at java.nio.ByteBuffer.allocateDirect(Unknown Source)
at com.jogamp.common.nio.Buffers.newDirectByteBuffer(Buffers.java:69)
at com.jogamp.common.nio.Buffers.newDirectFloatBuffer(Buffers.java:111)
at org.scilab.modules.renderer.JoGLView.util.BufferAllocation.newFloatBuffer(Unknown Source)
at org.scilab.modules.renderer.JoGLView.DataManager.fillColorBuffer(Unknown Source)
at org.scilab.modules.renderer.JoGLView.DataManager.getColorBuffer(Unknown Source)
at org.scilab.modules.renderer.JoGLView.DrawerVisitor.visit(Unknown Source)
at org.scilab.modules.graphic_objects.imageplot.Grayplot.accept(Unknown Source)
at org.scilab.modules.renderer.JoGLView.DrawerVisitor.askAcceptVisitor(Unknown Source)
at org.scilab.modules.renderer.JoGLView.axes.AxesDrawer.draw(Unknown Source)
at org.scilab.modules.renderer.JoGLView.DrawerVisitor.visit(Unknown Source)
at org.scilab.modules.graphic_objects.axes.Axes.accept(Unknown Source)
at org.scilab.modules.renderer.JoGLView.DrawerVisitor.askAcceptVisitor(Unknown Source)
at org.scilab.modules.renderer.JoGLView.DrawerVisitor.visit(Unknown Source)
at org.scilab.modules.graphic_objects.figure.Figure.accept(Unknown Source)
at org.scilab.modules.renderer.JoGLView.DrawerVisitor.draw(Unknown Source)
at org.scilab.forge.scirenderer.implementation.g2d.G2DCanvas.draw(Unknown Source)
at org.scilab.forge.scirenderer.implementation.g2d.G2DCanvas.redraw(Unknown Source)
at org.scilab.modules.graphic_export.Export.exportVectorial(Unknown Source)
at org.scilab.modules.graphic_export.Export.exportVectorial(Unknown Source)
at org.scilab.modules.graphic_export.Export.export(Unknown Source)
at org.scilab.modules.graphic_export.FileExporter.fileExport(Unknown Source)
*** buffer overflow detected ***: scilab-bin terminated
======= Backtrace: =========
/lib/libc.so.6(__fortify_fail+0x37)[0x7fb42c4517e7]
/lib/libc.so.6(+0xfe6a0)[0x7fb42c4506a0]
/lib/libc.so.6(+0xfd557)[0x7fb42c44f557]
/home/amonmayr/softs/scilab-master-1335282101/lib/scilab/libscilab-cli.so.5(+0x17b7ce)[0x7fb4341ce7ce]
/lib/libpthread.so.0(+0xf8f0)[0x7fb42cdaa8f0]
/lib/libc.so.6(gsignal+0x35)[0x7fb42c385a75]
/lib/libc.so.6(abort+0x180)[0x7fb42c3895c0]
/home/amonmayr/softs/scilab-master-1335282101/lib/thirdparty/libstdc++.so.6(_ZN9__gnu_cxx27__verbose_terminate_handlerEv+0x115)[0x7fb42d9a3965]
/home/amonmayr/softs/scilab-master-1335282101/lib/thirdparty/libstdc++.so.6(+0xc6d96)[0x7fb42d9a1d96]
/home/amonmayr/softs/scilab-master-1335282101/lib/thirdparty/libstdc++.so.6(+0xc6dc3)[0x7fb42d9a1dc3]
/home/amonmayr/softs/scilab-master-1335282101/lib/thirdparty/libstdc++.so.6(+0xc6ebe)[0x7fb42d9a1ebe]
/home/amonmayr/softs/scilab-master-1335282101/lib/scilab/libscigraphic_export.so.5(_ZN33org_scilab_modules_graphic_export12FileExporter10fileExportEP7JavaVM_PKcS4_ifi+0x27b)[0x7fb435d4c8db]
/home/amonmayr/softs/scilab-master-1335282101/lib/scilab/libscigraphic_export.so.5(xs2file+0x4f7)[0x7fb435d4bf67]
/home/amonmayr/softs/scilab-master-1335282101/lib/scilab/libscigraphic_export.so.5(gw_graphic_export+0x117)[0x7fb435d4b3c7]
/home/amonmayr/softs/scilab-master-1335282101/lib/scilab/libscilab-cli.so.5(callDynamicGateway+0x52)[0x7fb4341b1b82]
/home/amonmayr/softs/scilab-master-1335282101/lib/scilab/libscilab-cli.so.5(gw_dynamic_generic+0x36)[0x7fb4341fdd06]
/home/amonmayr/softs/scilab-master-1335282101/lib/scilab/libscilab-cli.so.5(callinterf_+0x44)[0x7fb4341d7964]
/home/amonmayr/softs/scilab-master-1335282101/lib/scilab/libscilab-cli.so.5(scirun_+0x151)[0x7fb4341c4cc1]
/home/amonmayr/softs/scilab-master-1335282101/lib/scilab/libscilab-cli.so.5(realmain+0x13d)[0x7fb4341c040d]
scilab-bin(main+0x1cc)[0x4016dc]
/lib/libc.so.6(__libc_start_main+0xfd)[0x7fb42c370c4d]
scilab-bin[0x401449]
======= Memory map: ========
00400000-00402000 r-xp 00000000 00:19 5523285 /home/amonmayr/softs/scilab-master-1335282101/bin/scilab-bin
00602000-00603000 r--p 00002000 00:19 5523285 /home/amonmayr/softs/scilab-master-1335282101/bin/scilab-bin
00603000-00604000 rw-p 00003000 00:19 5523285 /home/amonmayr/softs/scilab-master-1335282101/bin/scilab-bin
01499000-02cff000 rw-p 00000000 00:00 0 [heap]
401b4000-401b6000 r-xs 00000000 08:01 534529 /tmp/glx8mEWQ (deleted)
413dc000-41457000 rw-p 00000000 00:00 0
418b0000-4192b000 rw-p 00000000 00:00 0
7fb3d3732000-7fb3d741d000 rw-p 00000000 00:00 0
7fb3d741d000-7fb3d781d000 rw-s 2f12a000 00:05 8840 /dev/nvidia0
7fb3d781d000-7fb3d8ef5000 rw-p 00000000 00:00 0
7fb3d8ef5000-7fb3dcbdf000 rw-s 344c9000 00:05 8840 /dev/nvidia0
7fb3dcbdf000-7fb3e08c9000 rw-p 00000000 00:00 0
7fb3e08c9000-7fb3e45b3000 rw-s 5211f000 00:05 8840 /dev/nvidia0
7fb3e45b3000-7fb3e829d000 rw-p 00000000 00:00 0
7fb3e9976000-7fb3f134c000 rw-p 00000000 00:00 0
7fb3f16be000-7fb3f1e60000 rw-p 00000000 00:00 0 Aborted