You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix SIGBUS when saving PNG on Apple Silicon (#1410)
### **User description**
## Summary
- add zlib_compress_into subroutine to avoid returning large
allocatables from functions
- keep existing zlib_compress function as wrapper for backwards
compatibility
- update raster/pdf backends to call the new helper and add optional
debug logging
## Testing
- fpm test
___
### **PR Type**
Bug fix, Enhancement
___
### **Description**
- Add `zlib_compress_into` subroutine to avoid returning large
allocatables
- Keep existing `zlib_compress` function as backwards-compatible wrapper
- Update PNG and PDF backends to use new helper
- Add optional debug logging with environment variable control
___
### Diagram Walkthrough
```mermaid
flowchart LR
A["zlib_compress function"] --> B["zlib_compress_into subroutine"]
B --> C["PNG backend"]
B --> D["PDF backend"]
B --> E["Debug logging"]
A --> F["Backwards compatibility wrapper"]
```
<details> <summary><h3> File Walkthrough</h3></summary>
<table><thead><tr><th></th><th align="left">Relevant
files</th></tr></thead><tbody><tr><td><strong>Enhancement</strong></td><td><table>
<tr>
<td>
<details>
<summary><strong>fortplot_zlib_core.f90</strong><dd><code>Add safer
compression subroutine with debug logging</code>
</dd></summary>
<hr>
src/external/fortplot_zlib_core.f90
<ul><li>Add <code>zlib_compress_into</code> subroutine that allocates
output buffer <br>directly<br> <li> Convert existing
<code>zlib_compress</code> to wrapper calling new subroutine<br> <li>
Add debug logging infrastructure with environment variable control<br>
<li> Add utility functions for environment parsing and case
conversion</ul>
</details>
</td>
<td><a
href="https://github.com/lazy-fortran/fortplot/pull/1410/files#diff-a88e04b74f6df05653fd8293cdb98c45343981c51bc782a5a54d2ee55e871444">+117/-24</a></td>
</tr>
<tr>
<td>
<details>
<summary><strong>fortplot_zlib.f90</strong><dd><code>Export new
compression subroutine in bridge module</code>
</dd></summary>
<hr>
src/external/fortplot_zlib.f90
<ul><li>Add <code>zlib_compress_into</code> to module exports<br> <li>
Update public interface to include both old and new compression
<br>functions</ul>
</details>
</td>
<td><a
href="https://github.com/lazy-fortran/fortplot/pull/1410/files#diff-11e72eef971d431a23ca9c3637c35fd311a7856f1016b8b55c0ad0af3a12bd0d">+3/-3</a>
</td>
</tr>
</table></td></tr><tr><td><strong>Bug fix</strong></td><td><table>
<tr>
<td>
<details>
<summary><strong>fortplot_png.f90</strong><dd><code>Update PNG backend
to use new compression subroutine</code>
</dd></summary>
<hr>
src/backends/raster/fortplot_png.f90
<ul><li>Update import to use <code>zlib_compress_into</code> instead of
<code>zlib_compress</code><br> <li> Replace function call with
subroutine call in <code>generate_png_data</code></ul>
</details>
</td>
<td><a
href="https://github.com/lazy-fortran/fortplot/pull/1410/files#diff-82ad17eefff2c68aa18f549db7efad68da2811533f2fc213343875f2293d6605">+2/-2</a>
</td>
</tr>
<tr>
<td>
<details>
<summary><strong>fortplot_pdf.f90</strong><dd><code>Update PDF backend
to use new compression subroutine</code>
</dd></summary>
<hr>
src/backends/vector/fortplot_pdf.f90
<ul><li>Update import to use <code>zlib_compress_into</code> instead of
<code>zlib_compress</code><br> <li> Replace function call with
subroutine call in heatmap wrapper</ul>
</details>
</td>
<td><a
href="https://github.com/lazy-fortran/fortplot/pull/1410/files#diff-b6808bf1e748bba7bf8e9d2e3508fbc62435a6cbc3eec4b2354c3f31bc319e2a">+2/-2</a>
</td>
</tr>
<tr>
<td>
<details>
<summary><strong>fortplot_pdf_io.f90</strong><dd><code>Update PDF I/O to
use new compression subroutine</code>
</dd></summary>
<hr>
src/backends/vector/fortplot_pdf_io.f90
<ul><li>Update import to use <code>zlib_compress_into</code> instead of
<code>zlib_compress</code><br> <li> Replace function call with
subroutine call in <code>write_content_object</code></ul>
</details>
</td>
<td><a
href="https://github.com/lazy-fortran/fortplot/pull/1410/files#diff-c9accba28af59737231fe1bc2218677eb9f7840fc05186d18a72623e8bf8cb6d">+2/-2</a>
</td>
</tr>
</table></td></tr></tr></tbody></table>
</details>
___
0 commit comments