Skip to content

Robovm app crashes if gc triggered and there are >=256 threads #583

@guillerodriguez

Description

@guillerodriguez

Issue details

If the garbage collector kicks in and there are >= 256 threads alive, the application will crash.

This is due to the following check in bwdgc:

if (GC_mach_threads_count == GC_MAX_MACH_THREADS) // 256
    ABORT("Too many threads");

This is a problem for two reasons:

  • Cannot be easily handled by application code
  • Behaviour is not obvious: an application can start >= 256 threads and that will not be a problem if the gc does not run

To avoid this I suggest that a check is added in Thread.start() and a RuntimeException is thrown (or perhaps a VirtualMachineError?) if that will exceed the 256 thread limit (note that this includes native threads).

This way at least the application will have a chance to capture the exception and perhaps do something useful with it.

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