Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with GCC 8 #62

Closed
spotrh opened this issue Mar 23, 2018 · 2 comments
Closed

Issue with GCC 8 #62

spotrh opened this issue Mar 23, 2018 · 2 comments

Comments

@spotrh
Copy link
Contributor

spotrh commented Mar 23, 2018

It is not clear to me if this is a compiler issue or an asymptote issue, but when I try to build asymptote 2.41 for Fedora 28 (using gcc 8.0.1), the build succeeds, but asy dumps core during make all:

  • make all
    ../asy -dir ../base -config "" -render=0 -h 2>&1 | grep -iv Asymptote > options
    ../asy -dir ../base -config "" -render=0 -f pdf -noprc Hobbycontrol.asy
    ../asy -dir ../base -config "" -render=0 -f pdf -noprc binarytreetest.asy
    ../asy -dir ../base -config "" -render=0 -f pdf -noprc quartercircle.asy
    ../asy -dir ../base -config "" -render=0 -f pdf -noprc leastsquares.asy
    ../asy -dir ../base -config "" -render=0 -f pdf -noprc logo.asy
    ../asy -dir ../base -config "" -render=0 -f pdf -noprc join3.asy
    ../asy -dir ../base -config "" -render=0 -f pdf -noprc helix.asy
    ../asy -dir ../base -config "" -render=0 -f pdf -noprc loggrid.asy
    ../asy -dir ../base -config "" -render=0 -f pdf -noprc beziercurve.asy
    ../asy -dir ../base -config "" -render=0 -f pdf -noprc log2graph.asy
    ../asy -dir ../base -config "" -render=0 -f pdf -noprc monthaxis.asy
    ../asy -dir ../base -config "" -render=0 -f pdf -noprc exp.asy
    ../asy -dir ../base -config "" -render=0 -f pdf -noprc loggraph.asy
    ../asy -dir ../base -config "" -render=0 -f pdf -noprc cube.asy
    ../asy -dir ../base -config "" -render=0 -f pdf -noprc errorbars.asy
    ../asy -dir ../base -config "" -render=0 -f pdf -noprc generalaxis.asy
    ../asy -dir ../base -config "" -render=0 -f pdf -noprc tile.asy
    ../asy -dir ../base -config "" -render=0 -f pdf -noprc shadedtiling.asy
    ../asy -dir ../base -config "" -render=0 -f pdf -noprc lineargraph.asy
    ../asy -dir ../base -config "" -render=0 -f pdf -noprc secondaryaxis.asy
    make: *** [Makefile:42: secondaryaxis.pdf] Aborted (core dumped)

gdb backtrace looks like this:

Core was generated by `../asy -dir ../base -config  -render=0 -f pdf -noprc secondaryaxis.asy'.
Program terminated with signal SIGABRT, Aborted.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
50	  return ret;
[Current thread is 1 (Thread 0x7efefef8f880 (LWP 7110))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x00007efefb126591 in __GI_abort () at abort.c:79
#2  0x0000562977da26c8 in std::__replacement_assert (
    __file=0x2 <error: Cannot access memory at address 0x2>, __line=-1874640560, __function=0x0, 
    __condition=0x0) at /usr/include/c++/8/x86_64-redhat-linux/bits/c++config.h:2389
#3  0x0000562977fcd5ff in std::__cxx11::basic_string<char, std::char_traits<char>, gc_allocator<char> >::operator[] (__pos=<optimized out>, this=<optimized out>) at /usr/include/c++/8/bits/char_traits.h:285
#4  camp::ifile::Read(std::__cxx11::basic_string<char, std::char_traits<char>, gc_allocator<char> >&) ()
    at fileio.cc:149
#5  0x0000562977eb0269 in camp::file::read<std::__cxx11::basic_string<char, std::char_traits<char>, gc_allocator<char> > > (this=0x562979832bb0, val="") at /usr/include/c++/8/bits/char_traits.h:285
#6  0x0000562977eb1ccc in run::readArray<std::__cxx11::basic_string<char, std::char_traits<char>, gc_allocator<char> > > (s=0x2, nx=0, ny=-1, nz=-1) at castop.h:109
#7  0x0000562977fb4127 in vm::stack::runWithOrWithoutClosure(vm::lambda*, vm::frame*, vm::frame*) ()
    at stack.cc:455
#8  0x0000562977fe8157 in runRunnable(absyntax::runnable*, trans::coenv&, vm::interactiveStack&, transMode) () at process.cc:168
#9  0x0000562977fefc9e in itree::run (this=0x56297947cd60, e=..., s=..., tm=TRANS_NORMAL)
    at process.cc:311
#10 0x0000562977fec9c7 in icore::doRun (this=0x7fff9043d000, purge=80, tm=TRANS_INTERACTIVE)
    at process.cc:234
#11 0x0000562977fe7991 in icore::process (purge=<optimized out>, this=<optimized out>) at process.cc:257
#12 ifile::process (purge=<optimized out>, this=<optimized out>) at process.cc:396
#13 processFile(std::__cxx11::basic_string<char, std::char_traits<char>, gc_allocator<char> > const&, bool) () at process.cc:877
#14 0x00005629780347df in asymain(void*) () at /usr/include/c++/8/bits/char_traits.h:320
#15 0x0000562977d87dcb in main () at main.cc:215
#16 0x00007efefb1281bb in __libc_start_main (main=0x562977d87d50 <main>, argc=10, argv=0x7fff9043d308, 
    init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fff9043d2f8)
    at ../csu/libc-start.c:308
#17 0x0000562977d87f7a in _start () at drawpath.cc:165
(gdb) 

@mtasaka
Copy link

mtasaka commented Mar 28, 2018

With -O0:

(gdb) up
#1  0x00007ffff44f15c1 in abort () from /lib64/libc.so.6
(gdb) 
#2  0x00005555555a0bbb in std::__replacement_assert (__file=0x55555588d760 "/usr/include/c++/8/bits/basic_string.h", __line=1048, 
    __function=0x55555588e860 <std::__cxx11::basic_string<char, std::char_traits<char>, gc_allocator<char> >::operator[](unsigned long)::__PRETTY_FUNCTION__> "std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator[](std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _Ch"..., __condition=0x55555588d74c "__pos <= size()") at /usr/include/c++/8/x86_64-redhat-linux/bits/c++config.h:2389
2389	    __builtin_abort();
(gdb) 
#3  0x00005555555cbd20 in std::__cxx11::basic_string<char, std::char_traits<char>, gc_allocator<char> >::operator[] (this=0x7fffffff55d0, __pos=18446744073709551615)
    at /usr/include/c++/8/bits/basic_string.h:1048
1048		__glibcxx_assert(__pos <= size());
(gdb) 
#4  0x00005555557f995a in camp::ifile::Read (this=0x555556781bb0, val="") at fileio.cc:149
149	  if(s[pos] == '\r') s.erase(pos,1);
(gdb) p s
$1 = ""
(gdb) p pos
$2 = 18446744073709551615

So at https://github.com/vectorgraphics/asymptote/blob/master/fileio.cc#L149 , s is std::string "", pos is (size_t)-1 and now gcc8 checks the access of s[(size_t)-1] and it causes abort.
Now gcc8 checks this type of access (i.e. std::string str: a = str[pos]) every time and make it abort if access is illegal.

johncbowman added a commit that referenced this issue Mar 28, 2018
@johncbowman
Copy link
Member

Thank you for tracking this bug down. It is fixed in commit 6ce2d6f.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants