This repository has been archived by the owner. It is now read-only.

longjmp() in threadpool causes infinite hang on OS X #1362

Closed
kkaefer opened this Issue Jul 19, 2011 · 4 comments

Comments

Projects
None yet
5 participants
@kkaefer

kkaefer commented Jul 19, 2011

A C addon that uses setjmp()/longjmp() in a libeio threadpool thread causes child_process.exec to go into an infinite hang. I reduced the test case on https://github.com/kkaefer/child_process_hang. When running node index.js, node won't react to any keyboard input anymore and will stay running infinitely. Only killing with -9 exits it. This seems to only happen on Mac OS X, not on any Linux system I, @yhahn and @bnoordhuis have tested.

@kkaefer kkaefer closed this Jul 19, 2011

@kkaefer kkaefer reopened this Jul 19, 2011

@bnoordhuis

This comment has been minimized.

Show comment Hide comment
@bnoordhuis

bnoordhuis Aug 4, 2011

Member

@kkkaefer, what does this program do when compiled with and without -pthread?

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <setjmp.h>

static sigjmp_buf env;

static void sigsegv(int signum) {
  (void) signum;
  siglongjmp(env, 1);
}

int main(void) {
  volatile sig_atomic_t n = 0;
  struct sigaction sa;

  memset(&sa, 0, sizeof sa);
  sa.sa_handler = sigsegv;
  sigemptyset(&sa.sa_mask);
  sigaction(SIGSEGV, &sa, NULL);

  if(sigsetjmp(env, 1) && n >= 10) {
    printf("Survived %d segfaults.\n", n);
    return 0;
  }
  else {
    n++;
    *(int *)NULL = 42; /* Force SIGSEGV. */
    return 1;
  }
}
Member

bnoordhuis commented Aug 4, 2011

@kkkaefer, what does this program do when compiled with and without -pthread?

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <setjmp.h>

static sigjmp_buf env;

static void sigsegv(int signum) {
  (void) signum;
  siglongjmp(env, 1);
}

int main(void) {
  volatile sig_atomic_t n = 0;
  struct sigaction sa;

  memset(&sa, 0, sizeof sa);
  sa.sa_handler = sigsegv;
  sigemptyset(&sa.sa_mask);
  sigaction(SIGSEGV, &sa, NULL);

  if(sigsetjmp(env, 1) && n >= 10) {
    printf("Survived %d segfaults.\n", n);
    return 0;
  }
  else {
    n++;
    *(int *)NULL = 42; /* Force SIGSEGV. */
    return 1;
  }
}
@kkaefer

This comment has been minimized.

Show comment Hide comment
@kkaefer

kkaefer Aug 4, 2011

It works in both cases, with -pthread and without -pthread. It prints "Survived 10 segfaults.", then exits cleanly with status code 0.

kkaefer commented Aug 4, 2011

It works in both cases, with -pthread and without -pthread. It prints "Survived 10 segfaults.", then exits cleanly with status code 0.

@diasdavid

This comment has been minimized.

Show comment Hide comment
@diasdavid

diasdavid Feb 13, 2014

@kkaefer can you confirm if this is still a thing nowadays? Probably not right?

@kkaefer can you confirm if this is still a thing nowadays? Probably not right?

@misterdjules

This comment has been minimized.

Show comment Hide comment
@misterdjules

misterdjules Nov 19, 2014

Adapted the original repro to node v0.10 (and libuv) in another repository. I couldn't reproduce the issue on MacOS X.

Closing for now but @kkaefer please feel free to reopen if you think it's still broken.

Adapted the original repro to node v0.10 (and libuv) in another repository. I couldn't reproduce the issue on MacOS X.

Closing for now but @kkaefer please feel free to reopen if you think it's still broken.

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