vectorgraphics / asymptote

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

Build fails on PDF docs with Bus error /asy -dir base -config "" -render=0 -l > asy.list #338

Closed barracuda156 closed 1 year ago

barracuda156 commented 2 years ago

2.81 and 2.82 fail with Bus errors when trying to generate pdfs.

On 10.6.8 (ppc32) I get:

cd doc && /usr/bin/make man
cd doc && /usr/bin/make faq
Creating asy-keywords.el
./asy -dir base -config "" -render=0 -l > asy.list
make[1]: Entering directory `/opt/local/var/macports/build/_opt_PPCRosettaPorts_graphics_asymptote/asymptote/work/asymptote-2.82/doc'
make[1]: `faq' is up to date.
make[1]: Leaving directory `/opt/local/var/macports/build/_opt_PPCRosettaPorts_graphics_asymptote/asymptote/work/asymptote-2.82/doc'
make[1]: Entering directory `/opt/local/var/macports/build/_opt_PPCRosettaPorts_graphics_asymptote/asymptote/work/asymptote-2.82/doc'
../asy -dir ../base -config "" -render=0 -h 2>&1 | grep -iv Asymptote > options
../asy -dir ../base -config "" -render=0 -f pdf -noprc Bode.asy
../asy -dir ../base -config "" -render=0 -f pdf -noprc CAD1.asy
../asy -dir ../base -config "" -render=0 -f pdf -noprc CDlabel.asy
../asy -dir ../base -config "" -render=0 -f pdf -noprc GaussianSurface.asy
make[1]: *** [GaussianSurface.pdf] Bus error
make[1]: *** Waiting for unfinished jobs....
/bin/sh: line 1:  5083 Bus error               ./asy -dir base -config "" -render=0 -l > asy.list
make: *** [asy-keywords.el] Error 138
make: *** Waiting for unfinished jobs....
make[1]: *** [CAD1.pdf] Bus error
make[1]: *** [Bode.pdf] Bus error
make[1]: *** [options] Error 1
make[1]: *** [CDlabel.pdf] Bus error
make[1]: Leaving directory `/opt/local/var/macports/build/_opt_PPCRosettaPorts_graphics_asymptote/asymptote/work/asymptote-2.82/doc'
make: *** [man] Error 2

A similar failure has been reported on 12.5 (M1): https://trac.macports.org/ticket/65584

barracuda156 commented 1 year ago

On 10.6 PPC (native PPC) asymptote 2.83 fails with:

Writing index file asy-latex.idx
(/opt/local/share/texmf-texlive/tex/latex/l3backend/l3backend-pdftex.def)
No file asy-latex.aux.
(./asy-latex.dtx
No file asy-latex.toc.
[1{/opt/local/var/db/texmf/fonts/map/pdftex/updmap/pdftex.map}] [2] [3]
[4] [5] [6] [7]
Overfull \hbox (19.48749pt too wide) in paragraph at lines 539--539
 [][]      \OT1/cmtt/m/n/9 \immediate\write\AsyStream{size(0,\ASYheight,\asy@ex
pand@keepAspect);}% 

Overfull \hbox (14.76254pt too wide) in paragraph at lines 539--539
 [][]      \OT1/cmtt/m/n/9 \immediate\write\AsyStream{size(\ASYwidth,0,\asy@exp
and@keepAspect);}% 

Overfull \hbox (57.28705pt too wide) in paragraph at lines 539--539
 [][]      \OT1/cmtt/m/n/9 \immediate\write\AsyStream{size(\ASYwidth,\ASYheight
,\asy@expand@keepAspect);}% 
[8]
Overfull \hbox (14.76254pt too wide) in paragraph at lines 593--593
 [][]            \OT1/cmtt/m/n/9 \setbox\ASYbox=\hbox{\includegraphics[hiresbb]
{\AsyFile+0.pdf}}% 

Overfull \hbox (5.31265pt too wide) in paragraph at lines 593--593
 [][]            \OT1/cmtt/m/n/9 \setbox\ASYbox=\hbox{\includegraphics[hiresbb]
{\AsyFile.pdf}}% 
[9] [10]) [11] (./asy-latex.aux) )
(see the transcript file for additional information)</opt/local/share/texmf-tex
live/fonts/type1/public/amsfonts/cm/cmbx10.pfb></opt/local/share/texmf-texlive/
fonts/type1/public/amsfonts/cm/cmbx12.pfb></opt/local/share/texmf-texlive/fonts
/type1/public/amsfonts/cm/cmbx9.pfb></opt/local/share/texmf-texlive/fonts/type1
/public/amsfonts/cm/cmr10.pfb></opt/local/share/texmf-texlive/fonts/type1/publi
c/amsfonts/cm/cmr12.pfb></opt/local/share/texmf-texlive/fonts/type1/public/amsf
onts/cm/cmr17.pfb></opt/local/share/texmf-texlive/fonts/type1/public/amsfonts/c
m/cmr6.pfb></opt/local/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmr7.
pfb></opt/local/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmr9.pfb></o
pt/local/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmss10.pfb></opt/lo
cal/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmss17.pfb></opt/local/s
hare/texmf-texlive/fonts/type1/public/amsfonts/cm/cmsy10.pfb></opt/local/share/
texmf-texlive/fonts/type1/public/amsfonts/cm/cmti10.pfb></opt/local/share/texmf
-texlive/fonts/type1/public/amsfonts/cm/cmtt10.pfb></opt/local/share/texmf-texl
ive/fonts/type1/public/amsfonts/cm/cmtt9.pfb>
Output written on asy-latex.pdf (11 pages, 207150 bytes).
Transcript written on asy-latex.log.
make[1]: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_graphics_asymptote/asymptote/work/asymptote-2.83/doc'
make: *** Waiting for unfinished jobs....
make: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_graphics_asymptote/asymptote/work/asymptote-2.83'
Command failed:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_graphics_asymptote/asymptote/work/asymptote-2.83" && /usr/bin/make -j4 -w all 
Exit code: 2
johncbowman commented 1 year ago

What happens if you specify -mask on the command line? For example,

../asy -dir ../base -config "" -render=0 -f pdf -noprc -mask GaussianSurface.asy

If this helps, then please see https://github.com/vectorgraphics/asymptote/issues/364.

barracuda156 commented 1 year ago

What happens if you specify -mask on the command line? For example,

../asy -dir ../base -config "" -render=0 -f pdf -noprc -mask GaussianSurface.asy

If this helps, then please see https://github.com/vectorgraphics/asymptote/issues/364.

I will try today and update you.

barracuda156 commented 1 year ago

In the latest release someone has broken back what was previously fixed:

make: Entering directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_graphics_asymptote/asymptote/work/asymptote-2.84'
pyrcc5 GUI/res/icons.qrc -o GUI/icons_rc.py
make: posix_spawn: pyrcc5: No such file or directory
make: Leaving directory `/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_graphics_asymptote/asymptote/work/asymptote-2.84'
Command failed:  cd "/opt/local/var/macports/build/_opt_PPCSnowLeopardPorts_graphics_asymptote/asymptote/work/asymptote-2.84" && /usr/bin/make -j2 -w all 
Exit code: 2

Fix was here:

commit 887964b07bc000c7d840d18370cded3561bdd263
Author: John Bowman <bowman@ualberta.ca>
Date:   Wed Aug 7 10:38:46 2019 -0600

    Don't attempt to install GUI files if unavailable (due to lack of pyuic5 and pyrcc5).

UPD. No, that is a new bug in fact.

johncbowman commented 1 year ago

The target is still qualified to continue on failure (note the -):

GUI/icons_rc.py: GUI/res/icons.qrc
    -$(PYRCC) GUI/res/icons.qrc -o GUI/icons_rc.py
johncbowman commented 1 year ago

Any news on the bus error? If your make isn't handling - correctly, you can touch GUI/icons_rc.py and continue compiling from there (the icons are just for xasy, which is not needed for this test).

barracuda156 commented 1 year ago

@johncbowman I need some time to unbreak other things. Your suggestion with touch GUI/icons_rc.py worked, but now this is broken:

In file included from runtime.in:84:
seconds.h: In function 'double utils::cpuTime()':
seconds.h:22:17: error: 'CLOCK_THREAD_CPUTIME_ID' was not declared in this scope
   22 |   clock_gettime(CLOCK_THREAD_CPUTIME_ID,&t);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~

UPD. This commit broke the build on every macOS < 10.12: https://github.com/vectorgraphics/asymptote/commit/4dafd8313cda0aad2a05abfdc91fc30ce88d7385 And while we have support for clock_gettime via legacysupport library, there is no CLOCK_THREAD_CPUTIME_ID there.

johncbowman commented 1 year ago

The portability of 2.84 is a separate issue. Let's focus on the FPE in this issue.

Please try with the 2.82 asy binary that you built when this issue was submitted: ./asy -dir base -mask -V GaussianSurface so that we can address one issue at a time.

barracuda156 commented 1 year ago

The portability of 2.84 is a separate issue. Let's focus on the FPE in this issue.

Please try with the 2.82 asy binary that you built when this issue was submitted: ./asy -dir base -mask -V GaussianSurface so that we can address one issue at a time.

Sure, I will update on it tomorrow.

johncbowman commented 1 year ago

Now that the 2.85 release is out, can we now close this issue?

barracuda156 commented 1 year ago

Now that the 2.85 release is out, can we now close this issue?

@johncbowman Sorry for a delay, I am away from native hardware due to travelling, and it is not convenient (or reliable) to test it in Rosetta.

I will try building 2.85 soon, and if it also happens to fail, gonna open a new issue.

johncbowman commented 1 year ago

If it still fails, please let us know if this works: ./asy -dir base -mask -V GaussianSurface That would simply mean that there is another division by zero in your graphics library, in addition to the ones we are currently ignoring.

barracuda156 commented 1 year ago

@johncbowman Whatever it was, apparently got fixed in 2.85. There are two minor errors in the code, but upon fixing those everything finally builds.

johncbowman commented 1 year ago

What "two minor errors" are you referring to?

barracuda156 commented 1 year ago

@johncbowman These:

In file included from runtime.in:84:
seconds.h: In function 'double utils::cpuTime()':
seconds.h:33:3: error: 'pthread_getcpuclockid' was not declared in this scope; did you mean 'pthread_getspecific'?
   33 |   pthread_getcpuclockid(pthread_self(),&cid);
      |   ^~~~~~~~~~~~~~~~~~~~~
      |   pthread_getspecific
glrender.cc: In function 'void gl::glrender(const mem::string&, const camp::picture*, const mem::string&, double, double, double, double, const camp::triple&, const camp::triple&, const camp::pair&, const camp::pair&, double*, double*, size_t, camp::triple*, double*, double*, bool, int)':
glrender.cc:1911:17: error: 'lasttime' was not declared in this scope; did you mean 'asctime'?
 1911 |   gettimeofday(&lasttime,NULL);
      |                 ^~~~~~~~
      |                 asctime
barracuda156 commented 1 year ago

This seems to fix both:

--- seconds.h.orig  2023-02-09 12:53:32.000000000 +0800
+++ seconds.h   2023-04-18 06:57:02.000000000 +0800
@@ -29,7 +29,7 @@
 #ifdef CLOCK_THREAD_CPUTIME_ID
   cid=CLOCK_THREAD_CPUTIME_ID;
 #else
- #ifdef HAVE_PTHREAD
+ #if defined(HAVE_PTHREAD) && !defined(__APPLE__)
   pthread_getcpuclockid(pthread_self(),&cid);
  #elif CLOCK_PROCESS_CPUTIME_ID
   cid=CLOCK_PROCESS_CPUTIME_ID;

--- glrender.cc.orig    2023-02-09 12:53:32.000000000 +0800
+++ glrender.cc 2023-04-18 06:56:21.000000000 +0800
@@ -1908,6 +1908,7 @@
               double *background, size_t nlightsin, triple *lights,
               double *diffuse, double *specular, bool view, int oldpid)
 {
+  timeval lasttime;
   gettimeofday(&lasttime,NULL);
   Iconify=getSetting<bool>("iconify");
johncbowman commented 1 year ago

That patch will cause other problems. The first problem is a MacOS X POSIX noncompliance; a workaround will be implemented in verion 2.86.

The fix for the second problem is in git. But the only reason you get the second error is that OpenGL is disabled. That means you are missing a critical library (maybe GLM?). The output of configure will tell you what you are missing and why.