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

Support malloc redirect on E2K #413

Closed
ivmai opened this issue Jan 12, 2022 · 3 comments
Closed

Support malloc redirect on E2K #413

ivmai opened this issue Jan 12, 2022 · 3 comments

Comments

@ivmai
Copy link
Owner

ivmai commented Jan 12, 2022

Host: Linux/e2k
Source: master
How to reproduce crash (all tests): ./configure --enable-redirect-malloc && make check

Note: not straightforward how to fix it - either need a way to access "real" malloc/free of libc or use GC_scratch_alloc (in GC_get_procedure_stack)

@ivmai
Copy link
Owner Author

ivmai commented Jan 16, 2022

Probably will need NO_PROC_FOR_LIBRARIES

ivmai added a commit that referenced this issue Jan 17, 2022
(refactoring)

Issue #413 (bdwgc).

* include/private/gc_priv.h [E2K] (GC_get_procedure_stack): Document
that the function mgiht be called from a signal handler.
* include/private/gc_priv.h [E2K] (GC_free_procedure_stack): New
function prototype.
* mach_dep.c [E2K] (GC_free_procedure_stack): Implement (just call
free() for now).
* mark_rts.c [!THREADS && !IA64 && E2K] (GC_push_current_stack): Call
GC_free_procedure_stack() instead of free().
* pthread_stop_world.c [E2K] (GC_suspend_handler_inner): Likewise.
* pthread_stop_world.c [E2K] (GC_push_all_stacks): Likewise.
* pthread_support.c [E2K] (GC_do_blocking_inner,
GC_call_with_gc_active): Likewise.
* pthread_stop_world.c [E2K] (GC_push_all_stacks): Move stack_size
local variable declaration to the innermost scope of its usage.
ivmai added a commit that referenced this issue Jan 17, 2022
Issue #413 (bdwgc).

* include/private/gc_priv.h [E2K] (GC_free_procedure_stack): Update
comment.
* pthread_stop_world.c [E2K] (GC_suspend_handler_inner): Do not call
free(); do not clear backing_store_ptr and backing_store_end fields
of me; add assertion that backing_store_end is null.
* pthread_stop_world.c [E2K] (GC_push_all_stacks): Set
backing_store_end and backing_store_end field of me even for self
thread; do not call free() for self thread.
* pthread_stop_world.c [E2K] (GC_start_world): Iterate over GC_threads
to call GC_free_procedure_stack (and clear backing_store_ptr and
backing_store_end) for each thread unless it is finished or blocked.
@ivmai
Copy link
Owner Author

ivmai commented Jan 19, 2022

The approach of using "real" malloc/free (obtained by dlopen/dlsym) does not work. (dlopen uses malloc itself).

ivmai added a commit that referenced this issue Jan 19, 2022
Issue #413 (bdwgc).

* include/private/gc_priv.h [E2K_USE_SCRATCH] (GC_e2k_ps_buffer,
GC_e2k_ps_capacity): Define macro.
* include/private/gcconfig.h [E2K && LINUX && REDIRECT_MALLOC
&& !GC_LINUX_THREADS] (E2K_USE_SCRATCH): Likewise.
* include/private/gc_priv.h [E2K_USE_SCRATCH] (_GC_arrays): Add
_e2k_ps_buffer and _e2k_ps_capacity fields; add comment.
* include/private/gcconfig.h [E2K && LINUX && REDIRECT_MALLOC
&& GC_LINUX_THREADS && !CPPCHECK]: Issue an error directive.
* mach_dep.c [E2K && E2K_USE_SCRATCH] (GC_free_procedure_stack): Do not
call free(); assert that buf is non-null but GC_e2k_ps_buffer is null;
set GC_e2k_ps_buffer to buf.
* mach_dep.c [E2K && E2K_USE_SCRATCH] (GC_get_procedure_stack):
Initialize buf local variable to GC_e2k_ps_buffer; initialize buf_sz
local variable to GC_e2k_ps_capacity; clear GC_e2k_ps_buffer value;
change FIXME item to TODO one; pass buf to GC_scratch_recycle_no_gww()
instead of free(); call GC_scratch_alloc() instead of malloc().
* mach_dep.c [E2K && LOG_E2K_ALLOCS] (GC_get_procedure_stack): Call
GC_log_printf() to print buf_sz, new_sz and GC_gc_no values if errno
is ENOMEM.
* mach_dep.c [E2K] (GC_get_procedure_stack): Ensure buf_sz<new_sz
(instead of buf_sz!=new_sz) after the loop; return new_sz instead of
buf_sz.
ivmai added a commit that referenced this issue Feb 1, 2022
Issue #413 (bdwgc).

* include/private/gcconfig.h [E2K && LINUX && REDIRECT_MALLOC]
(NO_PROC_FOR_LIBRARIES): Define macro.
@ivmai
Copy link
Owner Author

ivmai commented Feb 1, 2022

Commits 990dcdb and cbef64d should solve the issue.

@ivmai ivmai closed this as completed Feb 1, 2022
ivmai added a commit that referenced this issue Feb 2, 2022
Issue #413 (bdwgc).

* dyn_load.c [(SCO_ELF || DGUX || HURD || NACL || __ELF__ && (LINUX
|| FREEBSD || NETBSD || OPENBSD)) && USE_PROC_FOR_LIBRARIES && E2K
&& __ptr64__] (GC_register_map_entries): Skip c2fffffff000-c30000000000
anonymous writable section; add TODO.
@ivmai ivmai reopened this Feb 2, 2022
@ivmai ivmai closed this as completed Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant