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

Segmentation fault (core dumped) when listen to https using example WorkerThreads.js #1119

Open
snowinszu opened this issue Oct 21, 2024 · 0 comments

Comments

@snowinszu
Copy link

code like this:

if (isMainThread) {

	/* The acceptorApp only listens, but must be SSL if worker apps are SSL and likewise opposite */
	const acceptorApp = uWS.SSLApp({
		key_file_name: 'misc/key.pem',
		cert_file_name: 'misc/cert.pem',
		passphrase: '1234'
	  }).listen(port, (token) => {
		if (token) {
		  console.log('Listening to port ' + port + ' from thread ' + threadId + ' as main acceptor');
		} else {
		  console.log('Failed to listen to port ' + port + ' from thread ' + threadId);
		}
	  });

  /* Main thread loops over all CPUs */
  /* In this case we only spawn two (hardcoded) */
  /*os.cpus()*/[0, 1].forEach(() => {
	
    /* Spawn a new thread running this source file */
    new Worker(__filename).on("message", (workerAppDescriptor) => {
		acceptorApp.addChildAppDescriptor(workerAppDescriptor);
	});
  });

  /* I guess main thread joins by default? */
} else {
  /* Here we are inside a worker thread */
  const app = uWS.SSLApp({
    key_file_name: 'misc/key.pem',
    cert_file_name: 'misc/cert.pem',
    passphrase: '1234'
  }).get('/*', (res, req) => {
    res.end('Hello Worker!');
  }).listen(4000, (token) => {
	if (token) {
		console.log('Listening to port ' + 4000 + ' from thread ' + threadId);
	  } else {
		console.log('Failed to listen to port ' + 4000 + ' from thread ' + threadId);
	  }
  });

  /* The worker sends back its descriptor to the main acceptor */
  parentPort.postMessage(app.getDescriptor());
}

Testing on ubuntu 24.04

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

1 participant