[Lazarus] Printing BitMap on OSX crashes
Jesus Reyes A.
jesusrmx at gmail.com
Sat Aug 1 07:08:31 CEST 2015
En Fri, 31 Jul 2015 21:09:51 -0500, Martin Grajcar <maaartinus at gmail.com>
escribió:
> Hi Jesus,
>
>
>
> On Wed, Jul 1, 2015 at 10:52 PM, Jesus Reyes A. <jesusrmx at gmail.com>
> wrote:
>> On Tue, 30 Jun 2015 05:55:43 -0500, Martin Grajcar
>> <maaartinus at gmail.com> 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
>>> <maaartinus at gmail.com> 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-ide.org/pipermail/lazarus/attachments/20150801/edfc91a7/attachment-0003.html>
More information about the Lazarus
mailing list