Skip to content
This repository was archived by the owner on Jun 20, 2019. It is now read-only.

Conversation

@ibuclaw
Copy link
Member

@ibuclaw ibuclaw commented Aug 10, 2015

This will, eg: emit .value 0x0b0f on x86, or .inst 0xe7f000f0 on ARM.

This should reduce the size of Druntime/Phobos ever so slightly, as there will be no more dependencies on libc abort().

libgdruntime libgphobos helloworld
Before 5849kb 54.69mb 8569kb
After 5839kb 54.63mb 8560kb

So, is a subtle improvement.

@ibuclaw ibuclaw changed the title Use __builtin_trap to halt execution, rather than abort() Use builtin trap() to halt execution, rather than abort() Aug 11, 2015
@jpf91
Copy link
Contributor

jpf91 commented Aug 11, 2015

LGTM. Ready to merge?

@ibuclaw
Copy link
Member Author

ibuclaw commented Aug 11, 2015

Yep it's ready. Up to you if we want to discuss the change in behaviour.

With abort, the halted program would raise a SIGABRT signal deep in the guts of libgcc.

Program received signal SIGABRT, Aborted.
0x00007ffff7109cc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56      ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  0x00007ffff7109cc9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007ffff710d0d8 in __GI_abort () at abort.c:89
#2  0x0000000000403c9b in D main () at diemydarling.d:7

With this change, it instead raises a SIGILL signal at the exact point of the assert(0).

Program received signal SIGILL, Illegal instruction.
D main () at diemydarling.d:7

ARM and other targets might do something different, but at least they should guarantee halting the program.

@jpf91
Copy link
Contributor

jpf91 commented Aug 11, 2015

Sounds good.

jpf91 added a commit that referenced this pull request Aug 11, 2015
Use builtin trap() to halt execution, rather than abort()
@jpf91 jpf91 merged commit 78c3891 into D-Programming-GDC:master Aug 11, 2015
@ibuclaw ibuclaw deleted the halttrap branch August 11, 2015 11:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants