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

[pull] master from ruby:master #448

Merged
merged 5 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ install-prereq: $(CLEAR_INSTALLED_LIST) yes-fake sudo-precheck PHONY
clear-installed-list: PHONY
@> $(INSTALLED_LIST) set MAKE="$(MAKE)"

clean: clean-ext clean-enc clean-golf clean-docs clean-extout clean-gc clean-local clean-platform clean-spec
clean: clean-ext clean-enc clean-golf clean-docs clean-extout clean-modular-gc clean-local clean-platform clean-spec
clean-local:: clean-runnable
$(Q)$(RM) $(ALLOBJS) $(LIBRUBY_A) $(LIBRUBY_SO) $(LIBRUBY) $(LIBRUBY_ALIASES)
$(Q)$(RM) $(PROGRAM) $(WPROGRAM) miniruby$(EXEEXT) dmyext.$(OBJEXT) dmyenc.$(OBJEXT) $(ARCHFILE) .*.time
Expand Down Expand Up @@ -751,14 +751,11 @@ clean-capi: PHONY
clean-platform: PHONY
clean-extout: PHONY
-$(Q)$(RMDIR) $(EXTOUT)/$(arch) $(RUBYCOMMONDIR) $(EXTOUT) 2> $(NULL) || $(NULLCMD)
clean-gc: PHONY
$(Q) $(RMALL) .gc
$(Q) $(RMALL) gc
clean-docs: clean-rdoc clean-html clean-capi
clean-spec: PHONY
clean-rubyspec: clean-spec

distclean: distclean-ext distclean-enc distclean-golf distclean-docs distclean-extout distclean-gc distclean-local distclean-platform distclean-spec
distclean: distclean-ext distclean-enc distclean-golf distclean-docs distclean-extout distclean-modular-gc distclean-local distclean-platform distclean-spec
distclean-local:: clean-local
$(Q)$(RM) $(MKFILES) *.inc $(PRELUDES) *.rbinc *.rbbin
$(Q)$(RM) config.cache config.status config.status.lineno
Expand All @@ -771,7 +768,6 @@ distclean-html: clean-html
distclean-capi: clean-capi
distclean-docs: clean-docs
distclean-extout: clean-extout
distclean-gc: clean-gc
distclean-platform: clean-platform
distclean-spec: clean-spec
distclean-rubyspec: distclean-spec
Expand Down Expand Up @@ -1958,10 +1954,12 @@ modular-gc: probes.h modular-gc-precheck
$(CP) gc/$(MODULAR_GC)/librubygc.$(MODULAR_GC).$(DLEXT) $(modular_gc_dir)

clean-modular-gc:
- $(CHDIR) gc/$(MODULAR_GC) && $(exec) $(MAKE) TARGET_SO_DIR=./ clean || $(NULLCMD)
- find gc -type d -mindepth 1 -maxdepth 1 -exec sh -c '$(CHDIR) "{}" && $(MAKE) TARGET_SO_DIR=./ clean || $(NULLCMD)' \; || $(NULLCMD)
-$(Q) $(RMDIR) gc
distclean-modular-gc: clean-modular-gc
- $(CHDIR) gc/$(MODULAR_GC) && $(exec) $(MAKE) TARGET_SO_DIR=./ distclean || $(NULLCMD)
$(RMALL) gc/$(MODULAR_GC)
- find gc -type d -mindepth 1 -maxdepth 1 -exec sh -c '$(CHDIR) "{}" && $(MAKE) TARGET_SO_DIR=./ distclean || $(NULLCMD)' \; || $(NULLCMD)
- find gc -type d -mindepth 1 -maxdepth 1 -exec sh -c '$(RMDIR) "{}"' \; || $(NULLCMD)
-$(Q) $(RMDIR) gc

help: PHONY
$(MESSAGE_BEGIN) \
Expand Down
39 changes: 29 additions & 10 deletions ext/objspace/objspace_dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ RUBY_EXTERN const char ruby_hexdigits[];
#define BUFFER_CAPACITY 4096

struct dump_config {
VALUE type;
VALUE stream;
VALUE given_output;
VALUE output_io;
VALUE string;
FILE *stream;
const char *root_category;
VALUE cur_obj;
VALUE cur_obj_klass;
Expand All @@ -58,7 +59,7 @@ dump_flush(struct dump_config *dc)
{
if (dc->buffer_len) {
if (dc->stream) {
size_t written = rb_io_bufwrite(dc->stream, dc->buffer, dc->buffer_len);
size_t written = fwrite(dc->buffer, sizeof(dc->buffer[0]), dc->buffer_len, dc->stream);
if (written < dc->buffer_len) {
MEMMOVE(dc->buffer, dc->buffer + written, char, dc->buffer_len - written);
dc->buffer_len -= written;
Expand Down Expand Up @@ -696,16 +697,34 @@ root_obj_i(const char *category, VALUE obj, void *data)
static void
dump_output(struct dump_config *dc, VALUE output, VALUE full, VALUE since, VALUE shapes)
{

dc->given_output = output;
dc->full_heap = 0;
dc->buffer_len = 0;

if (TYPE(output) == T_STRING) {
dc->stream = Qfalse;
dc->stream = NULL;
dc->string = output;
}
else {
dc->stream = output;
rb_io_t *fptr;
// Output should be an IO, typecheck and get a FILE* for writing.
// We cannot write with the usual IO code here because writes
// interleave with calls to rb_gc_mark(). The usual IO code can
// cause a thread switch, raise exceptions, and even run arbitrary
// ruby code through the fiber scheduler.
//
// Mark functions generally can't handle these possibilities so
// the usual IO code is unsafe in this context. (For example,
// there are many ways to crash when ruby code runs and mutates
// the execution context while rb_execution_context_mark() is in
// progress.)
//
// Using FILE* isn't perfect, but it avoids the most acute problems.
output = rb_io_get_io(output);
dc->output_io = rb_io_get_write_io(output);
rb_io_flush(dc->output_io);
GetOpenFile(dc->output_io, fptr);
dc->stream = rb_io_stdio_file(fptr);
dc->string = Qfalse;
}

Expand All @@ -729,13 +748,13 @@ dump_result(struct dump_config *dc)
{
dump_flush(dc);

if (dc->stream) {
fflush(dc->stream);
}
if (dc->string) {
return dc->string;
}
else {
rb_io_flush(dc->stream);
return dc->stream;
}
return dc->given_output;
}

/* :nodoc: */
Expand Down
6 changes: 4 additions & 2 deletions process.c
Original file line number Diff line number Diff line change
Expand Up @@ -1200,8 +1200,10 @@ rb_process_status_wait(rb_pid_t pid, int flags)
// We only enter the scheduler if we are "blocking":
if (!(flags & WNOHANG)) {
VALUE scheduler = rb_fiber_scheduler_current();
VALUE result = rb_fiber_scheduler_process_wait(scheduler, pid, flags);
if (!UNDEF_P(result)) return result;
if (scheduler != Qnil) {
VALUE result = rb_fiber_scheduler_process_wait(scheduler, pid, flags);
if (!UNDEF_P(result)) return result;
}
}

struct waitpid_state waitpid_state;
Expand Down
Loading