Coder Social home page Coder Social logo

Comments (9)

johncbowman avatar johncbowman commented on July 1, 2024

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/

from asymptote.

bernie-gh avatar bernie-gh commented on July 1, 2024

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

from asymptote.

johncbowman avatar johncbowman commented on July 1, 2024

What I would first suggest is:

make clean
./configure --disable-gc
make all

from asymptote.

bernie-gh avatar bernie-gh commented on July 1, 2024

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

from asymptote.

johncbowman avatar johncbowman commented on July 1, 2024

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

from asymptote.

bernie-gh avatar bernie-gh commented on July 1, 2024

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

from asymptote.

johncbowman avatar johncbowman commented on July 1, 2024

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!

from asymptote.

bernie-gh avatar bernie-gh commented on July 1, 2024

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

from asymptote.

johncbowman avatar johncbowman commented on July 1, 2024

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

from asymptote.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.