Skip to content

Commit

Permalink
Handle vm_bug in MMTk GC worker threads
Browse files Browse the repository at this point in the history
Do not attempt to get the execution context because it does not exist
for GC worker threads which are not Ruby threads.
  • Loading branch information
wks committed Oct 19, 2023
1 parent 1ae5cae commit e43c88d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
9 changes: 9 additions & 0 deletions error.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@
#include "ruby_assert.h"
#include "vm_core.h"

#if USE_MMTK
#include "internal/mmtk_support.h"
#endif

#include "builtin.h"

/*!
Expand Down Expand Up @@ -1036,6 +1040,11 @@ rb_bug_without_die(const char *fmt, va_list args)
const char *file = NULL;
int line = 0;

#if USE_MMTK
if (rb_mmtk_enabled_p() && rb_mmtk_is_mmtk_worker()) {
file = NULL;
} else
#endif
if (GET_EC()) {
file = rb_source_location_cstr(&line);
}
Expand Down
2 changes: 2 additions & 0 deletions internal/mmtk_support.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ VALUE rb_mmtk_harness_begin(VALUE _);
VALUE rb_mmtk_harness_end(VALUE _);

// Debugging
bool rb_mmtk_is_mmtk_worker(void);
bool rb_mmtk_is_mutator(void);
void rb_mmtk_assert_mmtk_worker(void);
void rb_mmtk_assert_mutator(void);

Expand Down
4 changes: 2 additions & 2 deletions mmtk_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -1223,13 +1223,13 @@ rb_mmtk_harness_end(VALUE _)
// Debugging
////////////////////////////////////////////////////////////////////////////////

static inline bool
bool
rb_mmtk_is_mmtk_worker(void)
{
return rb_mmtk_gc_thread_tls != NULL;
}

static inline bool
bool
rb_mmtk_is_mutator(void)
{
return ruby_native_thread_p();
Expand Down

0 comments on commit e43c88d

Please sign in to comment.