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

Optimized compile of serialise/Failures causes abort on x86 #1576

Closed
dipinhora opened this issue Feb 11, 2017 · 6 comments
Closed

Optimized compile of serialise/Failures causes abort on x86 #1576

dipinhora opened this issue Feb 11, 2017 · 6 comments

Comments

@dipinhora
Copy link
Contributor

Compiling/running the tests for the Serialise package results in an abort if the tests are compiled without debug with ponyc. This happens on both config=debug and config=release builds of ponyc. Additionally, this seems independent of llvm versions.

The following snippet shows what occurs:

vagrant@vagrant:~/ponyc$ uname -a
Linux vagrant 4.4.0-31-generic #50-Ubuntu SMP Wed Jul 13 00:06:14 UTC 2016 i686 i686 i686 GNU/Linux
vagrant@vagrant:~/ponyc$ ./build/debug/ponyc -d packages/serialise/
Building builtin -> /home/vagrant/ponyc/packages/builtin
Building packages/serialise/ -> /home/vagrant/ponyc/packages/serialise
Building ponytest -> /home/vagrant/ponyc/packages/ponytest
Building time -> /home/vagrant/ponyc/packages/time
Building collections -> /home/vagrant/ponyc/packages/collections
Generating
 Reachability
 Selector painting
 Data prototypes
 Data types
 Function prototypes
 Functions
 Descriptors
Writing ./serialise.o
Linking ./serialise
Warning: environment variable $CC undefined, using cc as the linker
vagrant@vagrant:~/ponyc$ ./serialise --filter=serialise/Failures
1 test started, 0 complete: serialise/Failures started
1 test started, 1 complete: serialise/Failures complete
---- Passed: serialise/Failures
----
---- 1 test ran.
---- Passed: 1
vagrant@vagrant:~/ponyc$ ./build/debug/ponyc packages/serialise/
Building builtin -> /home/vagrant/ponyc/packages/builtin
Building packages/serialise/ -> /home/vagrant/ponyc/packages/serialise
Building ponytest -> /home/vagrant/ponyc/packages/ponytest
Building time -> /home/vagrant/ponyc/packages/time
Building collections -> /home/vagrant/ponyc/packages/collections
Generating
 Reachability
 Selector painting
 Data prototypes
 Data types
 Function prototypes
 Functions
 Descriptors
Optimising
Writing ./serialise.o
Linking ./serialise
Warning: environment variable $CC undefined, using cc as the linker
vagrant@vagrant:~/ponyc$ ./serialise --filter=serialise/Failures
Aborted

Runing the command with gdb:

vagrant@vagrant:~/ponyc$ gdb ./serialise 
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./serialise...done.
(gdb) run  --filter=serialise/Failures
Starting program: /home/vagrant/ponyc/serialise --filter=serialise/Failures
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".
[New Thread 0xb6dc2b40 (LWP 18946)]
[New Thread 0xb65c1b40 (LWP 18947)]

Thread 3 "serialise" received signal SIGABRT, Aborted.
[Switching to Thread 0xb65c1b40 (LWP 18947)]
0xb7fdac31 in __kernel_vsyscall ()
(gdb) bt
#0  0xb7fdac31 in __kernel_vsyscall ()
#1  0xb7dfdea9 in __GI_raise (sig=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#2  0xb7dff407 in __GI_abort () at abort.c:89
#3  0x0806d315 in pony_throw () at src/libponyrt/lang/posix_except.c:37
#4  0x080724dc in ponyint_serialise_object (ctx=0xb7dc2c44, p=0x0, t=0x807d930, mutability=0)
    at src/libponyrt/gc/serialise.c:108
#5  0x080721d3 in pony_traceknown (ctx=0xb7dc2c44, p=0x0, t=0x807d930, m=0) at src/libponyrt/gc/trace.c:105
#6  0x08049c8a in _HasPointer_Trace ()
#7  0xb7dc2c44 in ?? ()
#8  0x080727a1 in pony_serialise (ctx=0xb7dc2c44, p=0xb4dba860, out=0xb4dba880) at src/libponyrt/gc/serialise.c:203
#9  0x08056286 in ?? ()
#10 0x0805c12f in ?? ()
#11 0x0805bb88 in ?? ()
#12 0x0804b532 in ponytest__TestRunner_Dispatch ()
#13 0x0806c594 in handle_message (ctx=0xb7dc2c44, actor=0xb4dc0f00, msg=0xb4dbc1a0) at src/libponyrt/actor/actor.c:103
#14 0x0806c713 in ponyint_actor_run (ctx=0xb7dc2c44, actor=0xb4dc0f00, batch=100) at src/libponyrt/actor/actor.c:158
#15 0x0806e32c in run (sched=0xb7dc2c00) at src/libponyrt/sched/scheduler.c:287
#16 0x0806e406 in run_thread (arg=0xb7dc2c00) at src/libponyrt/sched/scheduler.c:338
#17 0xb7fb0295 in start_thread (arg=0xb65c1b40) at pthread_create.c:333
#18 0xb7eb8eee in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:114
(gdb) up
#1  0xb7dfdea9 in __GI_raise (sig=6) at ../sysdeps/unix/sysv/linux/raise.c:54
54	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) up
#2  0xb7dff407 in __GI_abort () at abort.c:89
89	abort.c: No such file or directory.
(gdb) up
#3  0x0806d315 in pony_throw () at src/libponyrt/lang/posix_except.c:37
37	  abort();
(gdb) l
32	  exception.exception_class = 0x506F6E7900000000; // "Pony"
33	#endif
34	  exception.exception_cleanup = exception_cleanup;
35	  _Unwind_RaiseException(&exception);
36	
37	  abort();
38	}
39	
40	static void set_registers(struct _Unwind_Exception* exception,
41	  struct _Unwind_Context* context)
(gdb) up
#4  0x080724dc in ponyint_serialise_object (ctx=0xb7dc2c44, p=0x0, t=0x807d930, mutability=0)
    at src/libponyrt/gc/serialise.c:108
108	    pony_throw();
(gdb) l
103	  if(t->serialise == NULL)
104	  {
105	    // A type without a serialisation function raises an error.
106	    // This applies to Pointer[A] and MaybePointer[A].
107	    serialise_cleanup(ctx);
108	    pony_throw();
109	    return;
110	  }
111	
112	  serialise_t k;
@lisael
Copy link
Contributor

lisael commented Feb 16, 2017

It looks a lot like what @Praetonus describes in #1186 (comment)

Maybe a duplicate.

@SeanTAllen
Copy link
Member

@Praetonus agrees that this looks like #1186.

@SeanTAllen
Copy link
Member

@dipinhora is this still an issue?

@dipinhora
Copy link
Contributor Author

Still a segfault. But with a slightly different stack trace (see below). I tried with both llvm-3.9 and llvm-6.0. Same results.

The following snippet shows what occurs:

vagrant@ubuntu-xenial:~/ponyc$ uname -a
Linux ubuntu-xenial 4.4.0-127-generic #153-Ubuntu SMP Sat May 19 10:58:15 UTC 2018 i686 i686 i686 GNU/Linux
vagrant@ubuntu-xenial:~/ponyc$ ./build/debug/ponyc --version
0.22.5-23567c3 [debug]
compiled with: llvm 3.9.1 -- cc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
Defaults: pic=false ssl=openssl_0.9.0
vagrant@ubuntu-xenial:~/ponyc$ ./build/debug/ponyc -d packages/serialise/
Building builtin -> /home/vagrant/ponyc/packages/builtin
Building packages/serialise/ -> /home/vagrant/ponyc/packages/serialise
Building ponytest -> /home/vagrant/ponyc/packages/ponytest
Building time -> /home/vagrant/ponyc/packages/time
Building collections -> /home/vagrant/ponyc/packages/collections
Generating
 Reachability
 Selector painting
 Data prototypes
 Data types
 Function prototypes
 Functions
 Descriptors
Writing ./serialise.o
Linking ./serialise
vagrant@ubuntu-xenial:~/ponyc$ ./serialise --only=serialise/Failures
1 test started, 0 complete: serialise/Failures started
1 test started, 1 complete: serialise/Failures complete
---- Passed: serialise/Failures
----
---- 1 test ran.
---- Passed: 1
vagrant@ubuntu-xenial:~/ponyc$ ./build/debug/ponyc packages/serialise/
Building builtin -> /home/vagrant/ponyc/packages/builtin
Building packages/serialise/ -> /home/vagrant/ponyc/packages/serialise
Building ponytest -> /home/vagrant/ponyc/packages/ponytest
Building time -> /home/vagrant/ponyc/packages/time
Building collections -> /home/vagrant/ponyc/packages/collections
Generating
 Reachability
 Selector painting
 Data prototypes
 Data types
 Function prototypes
 Functions
 Descriptors
Optimising
Writing ./serialise.o
Linking ./serialise
vagrant@ubuntu-xenial:~/ponyc$ ./serialise --only=serialise/Failures
Aborted (core dumped)
vagrant@ubuntu-xenial:~/ponyc$ 

Runing the command with gdb:

vagrant@ubuntu-xenial:~/ponyc$ gdb ./serialise
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./serialise...done.
(gdb) run  --only=serialise/Failures
Starting program: /home/vagrant/ponyc/serialise --only=serialise/Failures
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".
[New Thread 0xb6dc1b40 (LWP 18122)]
[New Thread 0xb65c0b40 (LWP 18123)]
[New Thread 0xb4dbfb40 (LWP 18124)]

Thread 3 "serialise" received signal SIGABRT, Aborted.
[Switching to Thread 0xb65c0b40 (LWP 18123)]
0xb7fdac31 in __kernel_vsyscall ()
(gdb) bt
#0  0xb7fdac31 in __kernel_vsyscall ()
#1  0xb7dfbea9 in __GI_raise (sig=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#2  0xb7dfd407 in __GI_abort () at abort.c:89
#3  0x0807c627 in pony_error () at src/libponyrt/lang/posix_except.c:39
#4  0x08086a82 in ponyint_serialise_actor (ctx=0xb7dc1444, actor=0xb45b7c00) at src/libponyrt/gc/serialise.c:144
#5  0x080838ca in pony_traceknown (ctx=0xb7dc1444, p=0xb45b7c00, t=0x80935d0, m=2) at src/libponyrt/gc/trace.c:112
#6  0x08056c5a in _HasActor_Trace ()
#7  0xb7dc1444 in ?? ()
#8  0x08086cb8 in pony_serialise (ctx=0xb7dc1444, p=0xb45b8080, t=0x0, out=0xb45b80a0, alloc_fn=0x80714f0 <$1$0_apply_oZo>)
    at src/libponyrt/gc/serialise.c:214
#9  0x080715c1 in ?? ()
#10 0x0806f01c in ?? ()
#11 0x0805a4c8 in ?? ()
#12 0x08056e05 in ponytest__TestRunner_Dispatch ()
#13 0x0807d493 in handle_message (ctx=0xb7dc1444, actor=0xb45bef00, msg=0xb45b8880) at src/libponyrt/actor/actor.c:164
#14 0x0807d59c in ponyint_actor_run (ctx=0xb7dc1444, actor=0xb45bef00, batch=100) at src/libponyrt/actor/actor.c:226
#15 0x08082171 in run (sched=0xb7dc1400) at src/libponyrt/sched/scheduler.c:794
#16 0x08082256 in run_thread (arg=0xb7dc1400) at src/libponyrt/sched/scheduler.c:835
#17 0xb7faf295 in start_thread (arg=0xb65c0b40) at pthread_create.c:333
#18 0xb7eb70ae in clone () at ../sysdeps/unix/sysv/linux/i386/clone.S:114
(gdb) up
#1  0xb7dfbea9 in __GI_raise (sig=6) at ../sysdeps/unix/sysv/linux/raise.c:54
54	../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) up
#2  0xb7dfd407 in __GI_abort () at abort.c:89
89	abort.c: No such file or directory.
(gdb) up
#3  0x0807c627 in pony_error () at src/libponyrt/lang/posix_except.c:39
39	  abort();
(gdb) l
34	  exception.exception_class = PONY_EXCEPTION_CLASS;
35	#endif
36	  exception.exception_cleanup = exception_cleanup;
37	  _Unwind_RaiseException(&exception);
38	
39	  abort();
40	}
41	
42	static void set_registers(struct _Unwind_Exception* exception,
43	  struct _Unwind_Context* context)
(gdb) up
#4  0x08086a82 in ponyint_serialise_actor (ctx=0xb7dc1444, actor=0xb45b7c00) at src/libponyrt/gc/serialise.c:144
144	  pony_error();
(gdb) l
139	void ponyint_serialise_actor(pony_ctx_t* ctx, pony_actor_t* actor)
140	{
141	  (void)ctx;
142	  (void)actor;
143	  serialise_cleanup(ctx);
144	  pony_error();
145	}
146	
147	PONY_API void pony_serialise_reserve(pony_ctx_t* ctx, void* p, size_t size)
148	{
(gdb) 

@dipinhora
Copy link
Contributor Author

Possibly related... As of current master both regex/Regex.groups and net/http/_HTTPConnection._new_conn also segfault. However, their backtraces seem to be corrupt.

regex/Regex.groups results:

vagrant@ubuntu-xenial:~/ponyc$ ./regex --only=regex/Regex
Segmentation fault (core dumped)
vagrant@ubuntu-xenial:~/ponyc$ gdb ./regex 
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./regex...done.
(gdb) run --only=regex/Regex
Starting program: /home/vagrant/ponyc/regex --only=regex/Regex
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".
[New Thread 0xb6d43b40 (LWP 2394)]
[New Thread 0xb6542b40 (LWP 2395)]
[New Thread 0xb4d41b40 (LWP 2396)]

Thread 3 "regex" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb6542b40 (LWP 2395)]
0x0805d0a2 in ?? ()
(gdb) bt
#0  0x0805d0a2 in ?? ()
#1  0xb4534a20 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb) 

net/http/_HTTPConnection._new_conn results:

vagrant@ubuntu-xenial:~/ponyc$ ./http --only=net/http/_
1 test started, 0 complete: net/http/_HTTPConnection._new_conn started
Segmentation fault (core dumped)
vagrant@ubuntu-xenial:~/ponyc$ gdb ./http
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "i686-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./http...done.
(gdb) run --only=net/http/_
Starting program: /home/vagrant/ponyc/http --only=net/http/_
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".
[New Thread 0xb6b69b40 (LWP 2379)]
[New Thread 0xb6368b40 (LWP 2380)]
1 test started, 0 complete: net/http/_HTTPConnection._new_conn started
[New Thread 0xb4b67b40 (LWP 2381)]

Thread 3 "http" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0xb6368b40 (LWP 2380)]
0x00000000 in ?? ()
(gdb) bt
#0  0x00000000 in ?? ()
#1  0x00000040 in ?? ()
#2  0x00000001 in ?? ()
#3  0xb4359c00 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb) 

@SeanTAllen
Copy link
Member

No longer able to reproduce.

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