Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2015-06

Printing BitMap on OSX crashes

8 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Martin Grajcar

My trivial Lazarus 1.4 application (and also our real application) crash whenever it prints a TBitMap on MAC. It happens in _platform_memmove$VARIANT$sse4 it tries to execute MOVDQA and I thought it was an alignment problem, but it isn't.

I'm attaching my rather confusing demo. It does nothing but printing and seems to work fine on Linux, but crashes on OSX. Commenting out the StretchDraw prevents the crash. I have currently no access to the MAC, so I apologize for not including a minimal example.

Regards, Martin.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150625/d500995e/attachment-0001.html> -------------- next part --------------
A non-text attachment was scrubbed...
Name: bitmap-crash.demo.zip
Type: application/zip
Size: 129784 bytes
Desc: not available
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150625/d500995e/attachment-0001.zip>

Reply by email

Martin Grajcar
to Martin Grajcar

Hello,

apologies for reposting, but I can't see in the archives (and have received no answer).

Are attachments forbidden here? I'm given you a link instead: https://dl.dropboxusercontent.com/u/4971686/bitmap-crash.demo.zip

Regards, Martin.

Martin Grajcar wrote 10 lines
My trivial Lazarus 1.4 application (and also our real application) crash whenever it prints a TBitMap on MAC. It happens in _platform_memmove$VARIANT$sse4 it tries to execute MOVDQA and I thought it was an alignment problem, but it isn't. I'm attaching my rather confusing demo. It does nothing but printing and seems to work fine on Linux, but crashes on OSX. Commenting out the StretchDraw prevents the crash. I have currently no access to the MAC, so I apologize for not including a minimal example.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150630/54a5a618/attachment.html>

Reply by email

Jesus Reyes A.
to Martin Grajcar
Martin Grajcar wrote 23 lines
Hello, apologies for reposting, but I can't see in the archives (and have received no answer). Are attachments forbidden here? I'm given you a link instead: https://dl.dropboxusercontent.com/u/4971686/bitmap-crash.demo.zip Regards, Martin. On Thu, Jun 25, 2015 at 10:57 AM, Martin Grajcar wrote: > My trivial Lazarus 1.4 application (and also our real application) > crash whenever it prints a TBitMap on MAC. It >>happens in > _platform_memmove$VARIANT$sse4 it tries to execute MOVDQA > and I thought it was an alignment problem, but it isn't. > > I'm attaching my rather confusing demo. It does nothing but printing > and seems to work fine on Linux, but crashes >>on OSX. Commenting out > the StretchDraw prevents the crash. I have currently no access to the > MAC, so I apologize >>for not including a minimal example.

I can reproduce it, and although the AV is easily fixed it seems printing bitmaps under Mac OS X it currently broken (loading a bitmap from a file doesn't produce AV but it not working anyway). I'm sure it used to work because I have PDF file generated using TPrinter and CUPS-PDF at some point.

Please submit a report so it wont be forgotten.

Jesus Reyes A.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150701/f0b3f551/attachment.html>

Reply by email

Vincent Snijders
to Martin Grajcar: apologies for reposting, but I can't see in the archives (and have received no answer).…

2015-06-30 12:55 GMT+02:00 Martin Grajcar :

Show quoted text 11 lines
Hello, apologies for reposting, but I can't see in the archives (and have received no answer). Are attachments forbidden here? I'm given you a link instead: https://dl.dropboxusercontent.com/u/4971686/bitmap-crash.demo.zip

Attachments larger than 100 kb require moderator approval. You should have received an e-mail from the list manger software, that your e-mail was held because of the large attachment.

Vincent
List admin.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150713/63c669db/attachment.html>

Reply by email

Martin Grajcar
to Jesus Reyes A.: On Tue, 30 Jun 2015 05:55:43 -0500, Martin Grajcar I can reproduce it, and although the…

Hi Jesus,

Jesus Reyes A. wrote 33 lines
On Tue, 30 Jun 2015 05:55:43 -0500, Martin Grajcar wrote: Hello, apologies for reposting, but I can't see in the archives (and have received no answer). Are attachments forbidden here? I'm given you a link instead: https://dl.dropboxusercontent.com/u/4971686/bitmap-crash.demo.zip Regards, Martin. On Thu, Jun 25, 2015 at 10:57 AM, Martin Grajcar wrote: > My trivial Lazarus 1.4 application (and also our real application) crash > whenever it prints a TBitMap on MAC. It happens in > _platform_memmove$VARIANT$sse4 it tries to execute MOVDQA > and I thought it was an alignment problem, but it isn't. > > I'm attaching my rather confusing demo. It does nothing but printing and > seems to work fine on Linux, but crashes on OSX. Commenting out the > StretchDraw prevents the crash. I have currently no access to the MAC, so I > apologize for not including a minimal example. > I can reproduce it, and although the AV is easily fixed it seems printing bitmaps under Mac OS X it currently broken (loading a bitmap from a file doesn't produce AV but it not working anyway). I'm sure it used to work because I have PDF file generated using TPrinter and CUPS-PDF at some point.

I haven't a chance to try it yet. Just in case it's non exactly trivial, how can the AV be fixed? I was only accessing the MAC over a bad connection, which made pretty everything complicated.

I'm also sure it used to work.

Please submit a report so it wont be forgotten.

http://mantis.freepascal.org/view.php?id=28455

Regards, Martin.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150801/a9bd197b/attachment.html>

Reply by email

Jesus Reyes A.
to Martin Grajcar

En Fri, 31 Jul 2015 21:09:51 -0500, Martin Grajcar escribi?:

Show quoted text 50 lines
Hi Jesus, On Wed, Jul 1, 2015 at 10:52 PM, Jesus Reyes A. wrote: > On Tue, 30 Jun 2015 05:55:43 -0500, Martin Grajcar > wrote: > >> Hello, >> >> apologies for reposting, but I can't see in the archives (and have >> received no answer). >> >> Are attachments forbidden here? I'm given you a link instead: >> https://dl.dropboxusercontent.com/u/4971686/bitmap-crash.demo.zip >> >> Regards, Martin. >> >> On Thu, Jun 25, 2015 at 10:57 AM, Martin Grajcar >> wrote: >>> My trivial Lazarus 1.4 application (and also our real application) >>> crash whenever it prints a TBitMap on MAC. It happens in >>> _platform_memmove$VARIANT>>>>$sse4 it tries to execute MOVDQA >>> and I thought it was an alignment problem, but it isn't. >>> >>> I'm attaching my rather confusing demo. It does nothing but printing >>> and seems to work fine on Linux, but crashes on OSX. Commenting out >>> the StretchDraw >>>>prevents the crash. I have currently no access to >>> the MAC, so I apologize for not including a minimal example. >> > > I can reproduce it, and although the AV is easily fixed it seems > printing bitmaps under Mac OS X it currently broken (loading a bitmap > from a file doesn't produce AV >>but it not working anyway). I'm sure > it used to work because I have PDF file generated using TPrinter and > CUPS-PDF at some point. I haven't a chance to try it yet. Just in case it's non exactly trivial, how can the AV be fixed? I was only accessing the MAC over a bad connection, which made pretty >everything complicated. I'm also sure it used to work. > Please submit a report so it wont be forgotten. http://mantis.freepascal.org/view.php?id=28455 Regards, Martin.

The problem occurs because the bitmap is being freed before Printer.EndDoc. It is at this point that the bitmap data is used, but because it was already freed an AV occurs. I have actually fixed the problem, but in my current implementation resources are only be freed at program end. Which is not good if somebody are printing a lot. So I have not committed the fix, I have another plan and will try again soon.

In the mean time, the workaround it's easy (this is not the fix I mentioned before which would patch the LCL+Printer support). Just create the bitmap before Print.BeginDoc and free it after Print.EndDoc. That should work.

Jesus Reyes A.

Usando el cliente de correo de Opera: http://www.opera.com/mail/ -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150801/edfc91a7/attachment.html>

Reply by email

Martin Grajcar
to Jesus Reyes A.

Hi Jesus,

Jesus Reyes A. wrote 14 lines
The problem occurs because the bitmap is being freed before Printer.EndDoc. It is at this point that the bitmap data is used, but because it was already freed an AV occurs. I have actually fixed the problem, but in my current implementation resources are only be freed at program end. Which is not good if somebody are printing a lot. So I have not committed the fix, I have another plan and will try again soon. In the mean time, the workaround it's easy (this is not the fix I mentioned before which would patch the LCL+Printer support). Just create the bitmap before Print.BeginDoc and free it after Print.EndDoc. That should work.

it does, thanks a lot!

Maybe you can help me with this: How can I get the debugger (lazarus/gdb) show the C code? All I get for the innermost frames is an address and assembler. No idea what to install (and Google really didn't help).

Regards,
Martin.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20150802/70f73665/attachment.html>

Reply by email

Martin Frb
to Martin Grajcar
Martin Grajcar wrote 6 lines
Maybe you can help me with this: How can I get the debugger (lazarus/gdb) show the C code? All I get for the innermost frames is an address and assembler. No idea what to install (and Google really didn't help).

I dont know if that is it is, its gonna be tricky.

First of all:
The c code must be compiled with the same debug info (stabs or dwarf) as the pascal code.

I haven't followed the thread, so I do not know if the c code is in a library (dynamically loaded) or linked into the exe. If linked then the debug info must have been included by the linker. If in an library it must be in such a way gdb can load it(gdb should be able to load debug info for libraries, but I do not know the state of this for each platform).
If in a library then "DisableLoadSymbolsForLibraries" MUST NOT (is not allowed to) be set.
(
http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips#internal-error:_clear_dangling_display_expressions )

If all the above is given, then the IDE must know where the files are (probably need to add the to the project). Debug info does not include the source, it just has filename and line number.

-----------
you can watch gdb communications in the debug output window (view > debug windows). So you can see what gdb responds.

Also. if you open the disassembler and single step into the c code, I would *expect* (never tested) that the stack window shows filenames. If it does not, then the debug info is either not there, or not read by gdb.

--------
On top of that you can try to control gdb yourself. You can do this from the IDE.
** BUT ** This is not an official feature and never will be. This solely exists for developing/testing the debugger integration in the IDE (for Lazarus developers).
It exists as it is, no feature requests, no bug reports...

Also, it has no safeguards. It is easy to hang the entire IDE by using it (only when sending commands to gdb). So ensure everything is saved.

Compile the ide with DBG_WITH_DEBUGGER_DEBUG defined.

Restart the IDE, Open debug output window (view > debug windows). There is an edit field and a button (must press button, return does not work). You can send gdb commands.

Do not send any commands that perform run/step. This will loose the debug session.

Reply by email