Skip to content

Crash in Java/C# code: GADRegisterSignalHandlers: race condition in signal handler cause NULL handler to be installed once SIGBUS is handled. #555

Description

@dkimitsa

Hello,
GAD version v12.9.0.
Observer behaviour: when two thread has SIGBUS signal, first thread restores previous in chain, but second nulls it.
Reproducible: 100%

This causes C#/Java signals handlers to be removed from chain and they are not able to handle Null Pointer Exceptions in try/catch blocks.
Code to reproduce (RoboVM one):

Runnable NPE = () -> {
    try {
        ((String) null).equals("hello");
    } catch (NullPointerException ignored) {}
};
Thread t1 = new Thread(NPE);
Thread t2 = new Thread(NPE);
t1.start();
t2.start();

^^^ this code will crash.
It happens due possible scenarios:

  • thread1 and thread2 have both NPE at same time;
  • signals are raised in both of these;
  • first thread restores valid previous handler, removes GAM from handling and calls it;
  • second thread processing signal as it was raised before removed by thread 1;
  • second thread restores NULL handlers (e.g. not RoboVM ones) and call it;
  • crash

full investigation story

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions