justinethier / cyclone

:cyclone: A brand-new compiler that allows practical application development using R7RS Scheme. We provide modern features and a stable system capable of generating fast native binaries.
http://justinethier.github.io/cyclone/
MIT License
823 stars 42 forks source link

Allow specifying stack size for pthreads #477

Closed justinethier closed 3 years ago

justinethier commented 3 years ago

Alpine Linux uses a small stack size (128 KB) for pthreads. This is too small to work with Cyclone as we are currently configured to build.

justinethier commented 3 years ago

Here is a simple program to demonstrate whether the change works:

(import
  (scheme base)
  (scheme write)
  (srfi 18))

(define (ack m n)
  (cond ((= m 0) (+ n 1))
        ((= n 0) (ack (- m 1) 1))
        (else (ack (- m 1) (ack m (- n 1))))))

(let ((t (thread-start! (make-thread (lambda () (ack 3 10))))))
  (write (thread-join! t))
  (newline))

@nmeum I would expect the above program will crash on Alpine Linux unless Cyclone is compiled to set its own thread stack size, EG:

make CYC_PTHREAD_SET_STACK_SIZE=1
nmeum commented 3 years ago

Yep, can confirm that the program crashes without CYC_PTHREAD_SET_STACK_SIZE=1 and works fine with it. Though I noticed https://github.com/justinethier/cyclone/issues/476#issuecomment-898884369 while testing this.

justinethier commented 3 years ago

Well, that's great this change works! Let me close out this ticket and we can discuss the other issue separately.