vectorgraphics / asymptote

2D & 3D TeX-Aware Vector Graphics Language
https://asymptote.sourceforge.io/
GNU General Public License v3.0
547 stars 90 forks source link

Unable to create pdf, png or svg files with 2.80 on AMD Picasso #312

Closed zarniwhoop73 closed 2 years ago

zarniwhoop73 commented 2 years ago

With 2.80 on one of my machines (linux AMD Ryzen 5 3400G using AMD Picasso graphics, recent versions of everything including the Picasso AMD firmware, gcc-11.2.0) my attempts to create pdf, png or svg graphics produce plain white output). HTML ('webgl') works ok. These all work fine in 2.79.

When I run a simple test, pairs of buffer allocation failures are reported, such as

amdgpu: Failed to allocate a buffer: amdgpu: size : 3821465600 bytes amdgpu: alignment : 2097152 bytes amdgpu: domains : 4 amdgpu: flags : 4 (repeated)

The number of repeats, and the varying sizes of the failed buffers, seem to vary across runs, e.g. rerunning the same source creates different error messages.

In the system log, for each failed run I see [drm:amdgpu_job_timedout [amdgpu]] ERROR ring gfx timeout, but soft recovered

Updating mesa from 21.3.6 to 22.0.1 and then to 22.1.0-rc2 did not solve this.

Example asy file, 'cylpng.asy' : `settings.outformat = "png"; settings.prc = false; settings.render=4;

size(15cm,0); import three; draw(unitcylinder, mediumcyan+opacity(.5)); ` Similar results from changing the outformat to pdf or svg.

I have tried to use gdb on this, but gdb segfaults:

(gdb) break asymain Breakpoint 1 at 0x6fcb10: file main.cc, line 140. (gdb) dir /scratch/ken/testbuild/asymptote-2.80/ Source directories searched: /scratch/ken/testbuild/asymptote-2.80:$cdir:$cwd (gdb) step The program is not being run. (gdb) run Starting program: /opt/texlive/2022/bin/x86_64-linux/asy cylpng.asy [Thread debugging using libthread_db enabled] Using host libthread_db library "/usr/lib/libthread_db.so.1".

Program received signal SIGSEGV, Segmentation fault. 0x00007ffff7db5b96 in GC_find_limit_with_bound (p=0x8bc188 "", up=up@entry=0, bound=bound@entry=0x0) at extra/../os_dep.c:1011 1011 extra/../os_dep.c: No such file or directory. (gdb) bt

0 0x00007ffff7db5b96 in GC_find_limit_with_bound (p=0x8bc188 "", up=up@entry=0,

bound=bound@entry=0x0) at extra/../os_dep.c:1011

1 0x00007ffff7dc0768 in GC_find_limit (up=0, p=) at extra/../os_dep.c:1023

2 GC_init_linux_data_start () at extra/../os_dep.c:463

3 GC_init_linux_data_start () at extra/../os_dep.c:430

4 GC_init () at extra/../misc.c:1190

5 GC_init () at extra/../misc.c:901

6 0x00007ffff7dbf643 in GC_generic_malloc_inner (lb=lb@entry=23, k=k@entry=0)

at extra/../malloc.c:174

7 0x00007ffff7dc32cd in GC_generic_malloc (lb=23, k=0) at extra/../malloc.c:251

8 0x0000000000455c0a in GC_selective_alloc (ignore_off_page=,

n=<optimized out>) at /usr/include/gc/gc_allocator.h:128

9 gc_allocator_ignore_off_page::allocate (GC_n=, this=)

at /usr/include/gc/gc_allocator.h:244

10 std::allocator_traits<gc_allocator_ignore_off_page >::allocate (__n=,

__a=...) at /usr/include/c++/11.2.0/bits/alloc_traits.h:314

11 std::cxx11::basic_string<char, std::char_traits, gc_allocator_ignore_off_page >::_M_create (capacity=, __old_capacity=1, this=)

at /usr/include/c++/11.2.0/bits/basic_string.tcc:153

12 0x000000000045635c in std::cxx11::basic_string<char, std::char_traits, gc_allocator_ignore_off_page >::_M_construct<char const*> (end=, __beg=,

this=<optimized out>) at /usr/include/c++/11.2.0/bits/basic_string.tcc:219

13 std::__cxx11::basic_string<char, std::char_traits, gc_allocator_ignore_off_page >::basic_string (this=0x821320 , s=0x722044 "webgl/WebGLheader.html", a=...)

at /usr/include/c++/11.2.0/bits/basic_string.h:539

14 0x000000000043dd4e in __static_initialization_and_destruction_0 (

__initialize_p=<optimized out>, __priority=<optimized out>)
at /scratch/working/asymptote-2.80/settings.h:126

15 _GLOBAL__sub_IZN4camp11reportErrorERKNSt7cxx1112basic_stringIcSt11char_traitsIcE28gc_allocator_ignore_off_pageIcEEE () at camperror.cc:64

16 0x00007ffff6e60333 in call_init (env=, argv=0x7fffffffe728, argc=2)

at ../csu/libc-start.c:145

17 __libc_start_main_impl (main=0x4557b0 <main(int, char**)>, argc=2, argv=0x7fffffffe728,

init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, 

--Type for more, q to quit, c to continue without paging-- stack_end=0x7fffffffe718) at ../csu/libc-start.c:379

18 0x0000000000455b21 in _start () at ../sysdeps/x86_64/start.S:115

johncbowman commented 2 years ago

Does downgrading to 2.79 really solve the problem or is the issue really due to some other software that you have since upgraded?

If your examples work after downgrading to 2.79, try version 2.80 again with the command-line option -noGPUcompress.

zarniwhoop73 commented 2 years ago

I started by using a "normal" system on the same machine (i.e. with some hardening of the CFLAGS and CXXFLAGS, similar to what most distros use. After that I came back to this system which lacks use of my own CFLAGS, and is where I measure packages (relative build time, space) for beyond linuxfromscratch.

Since I knew that 2.78 had worked previously on this machine, and that 2.80 had failed I installed the following after installing texlive-2022 source: dvisvgm and its deps, glew and libsigsegv, asy-2.78, tested ok, asy-2.79, tested ok, asy-2.80, failed as before. I then checked a newer (zen2) APU with mesa-21.1.0, that was fine. Came back here, upgraded to mesa-21.1.0, still failed.

At that time I thought the number of error messages was going down, but I now realise they are random. Updated to mesa-22.1.0-rc2, still fails.

Since then I have updated firefox and my ca-certificates, and installed gdb no other changes.

That option is the default. Trying it failed, as expected, but this time with 7 pairs of error messages for buffer sizes of 3839016960 bytes, 3858796544 bytes, 3932811264 bytes,3842592768 bytes, 4273356800 bytes, 4223352832 bytes, 3763519488 bytes. All with alignment 2097152 bytes, domains 4, flags 4.

Using 'free' before and after this, although I suspect it probably doesn't say anything useful. commas added as thousands separators total used free shared buff/cache available Mem: 30,770,348 4,420,612 4,112,312 353,164 22,237,424 25,677,244 Swap: 16,777,212 338,156 16,439,056 and after total used free shared buff/cache available Mem: 30,770,348 8,855,692 1,842,120 325,860 20,072,536 21,167,048 Swap: 16,777,212 338,156 16,439,056

johncbowman commented 2 years ago

Can you confirm that 2.80 works fine with opacity(1.0) instead of opacity(0.5)?

zarniwhoop73 commented 2 years ago

Fails to run,

shipout3(prefix,f,preview ? nativeformat() : format,
        ^

/opt/texlive/2022/texmf-dist/asymptote/three.asy: 2896.13: runtime: ken@deluxe /scratch/ken/testbuild

Machine will be unavailable for the next two days.

johncbowman commented 2 years ago

To help isolate the problem try disabling gc: ./configure --disable-gc

If it still doesn't work it would be useful to know the first commit in the development git repo between tag 2.80git and 2.80 that fails. You can use git bisect for this. The only relevant changes in the 2.80 release affect transparency, so there should be no difference with opaque 3D examples.

zarniwhoop73 commented 2 years ago

No change with --disable-gc.

$git bisect log git bisect start

good: [94fe097db546f1de9e5b43e6b31fe1d2d4e4edaf] Increment version to 2.80.

git bisect good 94fe097db546f1de9e5b43e6b31fe1d2d4e4edaf

bad: [52f5c99018d24883f6e115ae72beaa88a15d0669] Fix last revision.

git bisect bad 52f5c99018d24883f6e115ae72beaa88a15d0669

bad: [50aaba78229e7401a1d3863ab3c4184dfc432585] TRANSPARENCY: Don't zero offset buffer.

git bisect bad 50aaba78229e7401a1d3863ab3c4184dfc432585

good: [dbafbb86b583bc1671f6111c7518219efb74de18] Merge conditionals.

git bisect good dbafbb86b583bc1671f6111c7518219efb74de18

good: [4c6980c4001d493e83d8ba5d11ba56d9f21c38c9] TRANSPARENCY: Conditionally define uniform.

git bisect good 4c6980c4001d493e83d8ba5d11ba56d9f21c38c9

good: [8b061a48bdf27b5e142bf48869087c73562169fb] TRANSPARENCY: Simplify code.

git bisect good 8b061a48bdf27b5e142bf48869087c73562169fb

good: [6ac4803bd0c0af840dcf8609087d521883fe46ca] TRANSPARENCY: Improve last revision.

git bisect good 6ac4803bd0c0af840dcf8609087d521883fe46ca

first bad commit: [50aaba78229e7401a1d3863ab3c4184dfc432585] TRANSPARENCY: Don't zero offset buffer.

johncbowman commented 2 years ago

Thank you for the helpful information. Two more questions will help narrow down the problem further (it seems from what you have reported that this only happens on exporting a rendered bitmap to a file, not when rendering to the screen):

  1. Does asy -noGPUindexing work on this file?
  2. What does asy --version report?
zarniwhoop73 commented 2 years ago

Yes, asy -noGPUindexing works for this file.

Asymptote version 2.80-17 [(C) 2004 Andy Hammerlindl, John C. Bowman, Tom Prince]

ENABLED OPTIONS: V3D 3D vector graphics output WebGL 3D HTML rendering OpenGL 3D OpenGL rendering SSBO GLSL shader storage buffer objects GSL GNU Scientific Library (special functions) FFTW3 Fast Fourier transforms XDR External Data Representation (portable binary file format for V3D) CURL URL support Readline Interactive history and editing Sigsegv Distinguish stack overflows from segmentation faults GC Boehm garbage collector threads Render OpenGL in separate thread

DISABLED OPTIONS: LSP Language Server Protocol

johncbowman commented 2 years ago

Can you please test the latest revision, de70a958b3844210142a9066b20bfce2a62bde4f?

zarniwhoop73 commented 2 years ago

Yes, asy -noGPUindexing works for this file.

Asymptote version 2.80-17 [(C) 2004 Andy Hammerlindl, John C. Bowman, Tom Prince]

ENABLED OPTIONS: V3D 3D vector graphics output WebGL 3D HTML rendering OpenGL 3D OpenGL rendering SSBO GLSL shader storage buffer objects GSL GNU Scientific Library (special functions) FFTW3 Fast Fourier transforms XDR External Data Representation (portable binary file format for V3D) CURL URL support Readline Interactive history and editing Sigsegv Distinguish stack overflows from segmentation faults GC Boehm garbage collector threads Render OpenGL in separate thread

DISABLED OPTIONS: LSP Language Server Protocol

zarniwhoop73 commented 2 years ago

That fixes it nicely, thanks..