Closed ombrophile closed 5 years ago
We are still trying to reproduce and track down this strange bug. You can follow the discussion here: https://sourceforge.net/p/asymptote/discussion/409349/thread/76353ab0/
Hello John, regarding garbage collector, I stayed with the version included in "asymptote-2.41.src.tgz". It is "gc-7.6.0.tar.gz". The system has version 7.2d installed (both at work and at home).
I can do builds on my machine at home with gc-7.6.0.tar.gz and gc-7.6.2.tar.gz. I will come back to you, when I have done them. bernie
What I would first suggest is:
make clean
./configure --disable-gc
make all
Hello John,
meanwhile I did three builds with different settings for Boehm-Demers-Weiser garbage collector on my machine at home (RHEL 7.3). Before building, I checked for missing libraries by means of:
$ ./configure | grep ’compile without’
Afterwards I added gsl-devel, fftw-devel, mesa-libOSMesa and mesa-libOSMesa-devel via yum to the system. Additionally, I downloaded gc-7.6.2.tar.gz and put it into the folder where the source archive was unpacked to.
The builds where done with three different configurations. The first one was without gc as you suggested:
$ ./configure --disable-gc
$ make all
the second one with gc-7.6.0:
$ make clean
$ ./configure
$ make all
and the third one with gc-7.6.2:
$ make clean
$ ./configure --enable-gc=7.6.2
$ make all
In all three cases the build stops, when processing diatom.asy due to the "additional %". Your suggestion on inserting
if(*format == "%") return "";
into the function string format(string *format, bool forcemath=false, string separator, real x, string locale=emptystring)
of runstring.in helps. Indeed, it would be nice to find the real cause.
How can I debug the C++ code behind asymptote? The chapter about debugging in the manual refers to processing *.asy-files only, doesn't it? bernie
For the TeXLive release, I've decided to add temporarily the line
if(*format == "%") return "";
patch but it is probably masking the real problem here.
Yes, the debugging discussed in the manual is for asy files. In this case the easiest way to debug
is probably (without the above patch) to insert cout statements like this in the code and send me the output of
asy -c "format('%',1.0)"
:
cout << "1: " << "[" << p << "]" << endl;
const char *tail=p; string f=format->substr(start-p0,tail-start);
const char *oldlocale=NULL; if(!locale.empty()) { oldlocale=setlocale(LC_ALL,NULL); if(oldlocale) oldlocale=StrdupNoGC(oldlocale); setlocale(LC_ALL,locale.c_str()); }
cout << "2: " << "[" << f << "]" << endl;
Int size=snprintf(NULL,0,f.c_str(),x)+1; if(size < 1) size=255; // Workaround for non-C99 compliant systems. char *buf=new char[size]; snprintf(buf,size,f.c_str(),x);
cout << "3: " << "[" << buf << "]" << endl;
Aside: The GNU debugger for c++ is called gdb. There is also a useful tool for checking for segmentation faults called valgrind. When using such tools you should normally disable garbage collection and debugging:
./configure --disable-gc make clean make CFLAGS=-g gdb asy run
Hello John,
as asymptote 2.44 is available, I did the build with the sources of this version. I added the extra cout
-statements as indicated above to the file runstring.in
. Furthermore the extra if
-statement of the "workaround" was commented out.
As expected the build stops at the processing of diatom.asy
. For testing the output within the folder, where I did $ make all
, I used:
$ ./asy -dir ./base -config "" -c "format('%',1.0)"
(no $ sudo make install
!).
The output is the following four lines:
1: []
2: [%]
3: [%]
%
So here the function call of snprintf(buf,size,f.c_str(),x);
does not result in what would be expected?
bernie
Exactly; the problem is with snprintf on your system. To be fair, the man page for snprintf doesn't explicitly specify the behaviour for the format string "%". Now let's test a few more possibilities:
./asy -dir ./base -config "" -c "format('% ',1.0)" ./asy -dir ./base -config "" -c "format('% %',1.0)" ./asy -dir ./base -config "" -c "format('% %%',1.0)" ./asy -dir ./base -config "" -c "format('% %%g',1.0)"
Thanks!
Hello John,
output of ./asy -dir ./base -config "" -c "format('% ',1.0)"
:
1: []
2: [% ]
3: [% ]
%
output of ./asy -dir ./base -config "" -c "format('% %',1.0)"
:
1: []
2: [% %]
3: [%]
%
output of ./asy -dir ./base -config "" -c "format('% %%',1.0)"
:
1: []
2: [% %%]
3: [%%]
%%
output of ./asy -dir ./base -config "" -c "format('% %%g',1.0)"
:
1: []
2: [% %%g]
3: [%1]
%1
bernie
For comparison, here is what I get on fc28 with gcc-8.1.1. The results of the first and third examples differ:
./asy -dir ./base -config "" -c "format('% ',1.0)"
1: []
2: [% ]
3: []
./asy -dir ./base -config "" -c "format('% %',1.0)"
1: []
2: [% %]
3: [%]
%
./asy -dir ./base -config "" -c "format('% %%',1.0)"
1: []
2: [% %%]
3: [%]
%
./asy -dir ./base -config "" -c "format('% %%g',1.0)"
1: []
2: [% %%g]
3: [%1]
%1
after installing all the required dependencies, if i issue 'make all', the compilation halts midway. If, instead, I call just 'make', compilation proceeds with success. This I checked with 'make check', and the results were all OK. After this, if I call 'make install', it halts in the same asy shell as before. But when calling asy from a new terminal runs just fine. After calling 'make install', terminal output of the last few statements before halting is as follows: