We've had challenges for SIGSEGV and SIGILL so why not...

Write the shortest code that results in a Bus Error (SIGBUS) in any programming language.

Your program can't call raise() or kill(getpid(),sig) or pthread_kill(pthread_self(),sig), or any other equivalent.

  • 1
    \$\begingroup\$ @ГригорийПерельман It's not a duplicate, no answer for that challenge can be applied to this one without nontrivial modification. \$\endgroup\$ – orlp Mar 21 '17 at 6:25
  • 6
    \$\begingroup\$ @orlp There are Bash, Python, Perl, and C answers that are all essentially raise(11). They can be trivially modified to be raise(7) instead for this challenge. \$\endgroup\$ – user45941 Mar 21 '17 at 6:55
  • 2
    \$\begingroup\$ Are you riding the SIGBUS, or driving it? \$\endgroup\$ – mbomb007 Mar 21 '17 at 19:13
  • \$\begingroup\$ Java/Groovy is also just System.exit(#); where you only change the # to throw a different exit code... This is a very trivial difference in many languages. \$\endgroup\$ – Magic Octopus Urn Mar 21 '17 at 19:29
  • \$\begingroup\$ @mbomb007 neither. You're throwing it. That seems like the most difficult of the three. \$\endgroup\$ – Cyoce Mar 23 '17 at 3:32

x86_64 bytecode, 15 bytes

   0:   c7 04 24 00 00 04 00    movl   $0x40000,(%rsp)
   7:   9d                      popfq  
   8:   8b 04 25 01 00 00 00    mov    0x1,%eax

Turns on the misaligned address trap flag and then immediately triggers it.


Not the answer you're looking for? Browse other questions tagged or ask your own question.