Permalink
Browse files

Minor changes. Looking for a bizarre crash occurring when kernel.rand…

…omize_va_space is 0 or 1 (not 2)
  • Loading branch information...
1 parent eb7bb8c commit 4c6d7e8cc30ed4c69e39fa341533a85c7ff06cb1 @lucasaiu committed Apr 19, 2013
View
@@ -18,6 +18,7 @@
#define CAML_CONTEXT_ROOTS
#define CAML_CONTEXT_MINOR_GC
+#include <assert.h> // FIXME: remove!!!!!!!!!!!!!!! Luca Saiu REENTRANTRUNTIME !!!!!!!!!!!!!!
#include "finalise.h"
#include "globroots.h"
#include "memory.h"
@@ -172,6 +173,8 @@ caml_acquire_global_lock();
sp = caml_bottom_of_stack;
retaddr = caml_last_return_address;
regs = caml_gc_regs;
+ assert(caml_gc_regs != (typeof(caml_gc_regs))0xaaaaaaaaaaaaaaaa); // FIXME: remove!!!!!!!!!!!!!!! Luca Saiu REENTRANTRUNTIME !!!!!!!!!!!!!!
+ assert(caml_gc_regs != (typeof(caml_gc_regs))0xbbbbbbbbbbbbbbbb); // FIXME: remove!!!!!!!!!!!!!!! Luca Saiu REENTRANTRUNTIME !!!!!!!!!!!!!!
if (sp != NULL) {
while (1) {
/* Find the descriptor corresponding to the return address */
@@ -266,6 +269,8 @@ caml_acquire_global_lock();
/* The stack and local roots */
if (caml_frame_descriptors == NULL) caml_init_frame_descriptors_r(ctx);
+ assert(caml_gc_regs != (typeof(caml_gc_regs))0xaaaaaaaaaaaaaaaa); // FIXME: remove!!!!!!!!!!!!!!! Luca Saiu REENTRANTRUNTIME !!!!!!!!!!!!!!
+ assert(caml_gc_regs != (typeof(caml_gc_regs))0xbbbbbbbbbbbbbbbb); // FIXME: remove!!!!!!!!!!!!!!! Luca Saiu REENTRANTRUNTIME !!!!!!!!!!!!!!
caml_do_local_roots_r(ctx, f, caml_bottom_of_stack, caml_last_return_address,
caml_gc_regs, caml_local_roots);
/* Global C roots */
View
Binary file not shown.
View
Binary file not shown.
View
@@ -354,6 +354,9 @@ section. */
ctx->intern_block;
*/
ctx->camlinternaloo_last_id = NULL;
+ /* intern_stack_init[INTERN_STACK_INIT_SIZE]; */
+ ctx->intern_stack = ctx->intern_stack_init;
+ ctx->intern_stack_limit = ctx->intern_stack_init + INTERN_STACK_INIT_SIZE;
/* from gc_ctrl.c */
ctx->caml_stat_minor_words = 0.0;
@@ -666,7 +669,7 @@ void caml_register_module_r(CAML_R, size_t size_in_bytes, long *offset_pointer){
int size_in_words = size_in_bytes / sizeof(void*);
/* We keep the module name right after the offset pointer, as a read-only string: */
char *module_name = (char*)offset_pointer + sizeof(long);
- //DUMP("module_name is %s", module_name);
+ DUMP("module_name is %s", module_name);
Assert(size_in_words * sizeof(void*) == size_in_bytes); /* there's a whole number of globals */
//fprintf(stderr, "caml_register_module_r [context %p]: registering %s%p [%lu bytes at %p]: BEGIN\n", ctx, module_name, offset_pointer, (unsigned long)size_in_bytes, offset_pointer); fflush(stderr);
View
@@ -224,6 +224,18 @@ typedef struct caml_thread_struct * caml_thread_t; /* from st_posix.h */
typedef pthread_t st_thread_id; /* from st_posix.h */
// ??????
+/* From intern.c: */
+/* Item on the stack with defined operation */
+struct intern_item {
+ value * dest;
+ intnat arg;
+ enum {
+ OReadItems, /* read arg items and store them in dest[0], dest[1], ... */
+ OFreshOID, /* generate a fresh OID and store it in *dest */
+ OShift /* offset *dest by arg */
+ } op;
+};
+
/* The field ordering should not be changed without also updating the
macro definitions at the beginning of asmrun/ARCHITECTURE.s. */
struct caml_global_context {
@@ -493,7 +505,10 @@ struct caml_global_context {
/* Point to the heap block allocated as destination block.
Meaningful only if intern_extra_block is NULL. */
value * camlinternaloo_last_id /* = NULL */;
-
+#define INTERN_STACK_INIT_SIZE 256
+ struct intern_item intern_stack_init[INTERN_STACK_INIT_SIZE];
+ struct intern_item * intern_stack /* = intern_stack_init */;
+ struct intern_item * intern_stack_limit /* = intern_stack_init + INTERN_STACK_INIT_SIZE */;
/* from gc_ctrl.c */
double caml_stat_minor_words; /* = 0.0, */
@@ -857,6 +872,9 @@ extern library_context *caml_get_library_context_r(
#define intern_header ctx->intern_header
#define intern_block ctx->intern_block
#define camlinternaloo_last_id ctx->camlinternaloo_last_id
+#define intern_stack_init ctx->intern_stack_init
+#define intern_stack ctx->intern_stack
+#define intern_stack_limit ctx->intern_stack_limit
#endif
/* caml_code_fragments_table is used both in extern.c and in intern.c;
View
@@ -186,7 +186,7 @@ char* caml_serialize_into_blob_r(CAML_R, value caml_value){
intnat blob_length;
flags = /* Marshal.Closures :: Marshal.Cross_context :: [] */
-//caml_pair_r(ctx, Val_int(0), /* Marshal.Closures, 1st constructor */
+//caml_pair_r(ctx, Val_int(0), /* Marshal.No_sharing, 1st constructor */
caml_pair_r(ctx,
///////// FIXME: replace with Val_int(2) for testing (only)
Val_int(1), /* Marshal.Closures, 2nd constructor */
@@ -198,9 +198,9 @@ char* caml_serialize_into_blob_r(CAML_R, value caml_value){
;
/* Marshal the big data structure into a byte array: */
-caml_acquire_global_lock(); // FIXME: remove after de-staticizing deserialization
+caml_acquire_global_lock(); // FIXME: I should be able to remove this RIGHT NOW: do it when the thing is stable
caml_output_value_to_malloc_r(ctx, caml_value, flags, &blob, &blob_length);
-caml_release_global_lock(); // FIXME: remove after de-staticizing deserialization
+caml_release_global_lock(); // FIXME: I should be able to remove this RIGHT NOW: do it when the thing is stable
//fprintf(stderr, "Ok-Q 100: ...serialized a structure into the blob at %p (length %.2fMB).\n", blob, blob_length / 1024. / 1024.); fflush(stderr);
CAMLreturnT(char*, blob);
@@ -209,15 +209,15 @@ caml_release_global_lock(); // FIXME: remove after de-staticizing deserializatio
value caml_deserialize_blob_r(CAML_R, char *blob){
CAMLparam0();
CAMLlocal1(result);
-caml_acquire_global_lock(); // FIXME: remove after de-staticizing deserialization
+caml_acquire_global_lock(); // FIXME: I should be able to remove this RIGHT NOW: do it when the thing is stable
result = caml_input_value_from_block_r(ctx,
blob,
/* FIXME: this third parameter is useless in practice: ask the OCaml people to
provide an alternate version of caml_input_value_from_block_r with two parameters.
I don't want to mess up the interface myself, since I'm doing a lot of other
invasive changes --Luca Saiu REENTRANTRUNTIME */
LONG_MAX);
-caml_release_global_lock(); // FIXME: remove after de-staticizing deserialization
+caml_release_global_lock(); // FIXME: I should be able to remove this RIGHT NOW: do it when the thing is stable
CAMLreturn(result);
}
@@ -448,8 +448,8 @@ CAMLprim value caml_context_split_r(CAML_R, value thread_no_as_value, value func
// DUMP("child threads have finished with the blob: destroying it");
caml_stat_free(blob);
// DUMP();
- caml_gc_compaction_r(ctx, Val_unit); //!!!!!
-// DUMP();
+ caml_gc_compaction_r(ctx, Val_unit); //!!!!!@@@@@@@@@@@@@
+ // DUMP();
caml_finalize_semaphore(&semaphore);
// DUMP();
@@ -458,7 +458,7 @@ CAMLprim value caml_context_split_r(CAML_R, value thread_no_as_value, value func
/* Copy the contexts we got, and we're done with new_contexts as well: */
// DUMP("copying the new context (descriptors) into the Caml data structure result");
result = caml_alloc_r(ctx, thread_no, 0);
- caml_gc_compaction_r(ctx, Val_unit); //!!!!!
+ caml_gc_compaction_r(ctx, Val_unit); //!!!!!@@@@@@@@@@@@
for(i = 0; i < thread_no; i ++)
caml_initialize_r(ctx, &Field(result, i), caml_value_of_context_descriptor(new_contexts[i]->descriptor));
caml_stat_free(new_contexts);
View
@@ -496,7 +496,8 @@ static void extern_rec_r(CAML_R, value v)
}
else if ((cf = extern_find_code_r(ctx, (char *) v)) != NULL) {
if (!extern_closures)
- extern_invalid_argument_r(ctx, "output_value: functional value");
+ //extern_invalid_argument_r(ctx, "output_value: functional value"); // FIXME: this is the correct version. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ {DUMP("output_value: functional value"); {volatile int a = 1; a /= 0;}}
//fprintf(stderr, "ZZZZ dumping a code pointer: BEGIN\n");
writecode32_r(ctx, CODE_CODEPOINTER, (char *) v - cf->code_start);
writeblock_r(ctx, (char *) cf->digest, 16);
View
@@ -150,30 +150,30 @@ static void readfloats_r(CAML_R, double * dest, mlsize_t len, unsigned int code)
#endif
}
-/* Item on the stack with defined operation */
-struct intern_item {
- value * dest;
- intnat arg;
- enum {
- OReadItems, /* read arg items and store them in dest[0], dest[1], ... */
- OFreshOID, /* generate a fresh OID and store it in *dest */
- OShift /* offset *dest by arg */
- } op;
-};
+/* /\* Item on the stack with defined operation *\/ */
+/* struct intern_item { */
+/* value * dest; */
+/* intnat arg; */
+/* enum { */
+/* OReadItems, /\* read arg items and store them in dest[0], dest[1], ... *\/ */
+/* OFreshOID, /\* generate a fresh OID and store it in *dest *\/ */
+/* OShift /\* offset *dest by arg *\/ */
+/* } op; */
+/* }; */
/* FIXME: This is duplicated in two other places, with the only difference of
the type of elements stored in the stack. Possible solution in C would
be to instantiate stack these function via. C preprocessor macro.
*/
-#define INTERN_STACK_INIT_SIZE 256
+//#define INTERN_STACK_INIT_SIZE 256
#define INTERN_STACK_MAX_SIZE (1024*1024*100)
-static struct intern_item intern_stack_init[INTERN_STACK_INIT_SIZE];
+/* static struct intern_item intern_stack_init[INTERN_STACK_INIT_SIZE]; */
-static struct intern_item * intern_stack = intern_stack_init;
-static struct intern_item * intern_stack_limit = intern_stack_init
- + INTERN_STACK_INIT_SIZE;
+/* static struct intern_item * intern_stack = intern_stack_init; */
+/* static struct intern_item * intern_stack_limit = intern_stack_init */
+/* + INTERN_STACK_INIT_SIZE; */
/* Free the recursion stack if needed */
static void intern_free_stack_r(CAML_R)
@@ -380,7 +380,7 @@ DUMP("this is the tick thread");
while(1) {
/* select() seems to be the most efficient way to suspend the
thread for sub-second intervals */
- timeout.tv_sec = 0;//2;//timeout.tv_sec = 0; // FIXME: this of course should be reset to 0 after debugging
+ timeout.tv_sec = 1;//timeout.tv_sec = 0; // FIXME: this of course should be reset to 0 after debugging
timeout.tv_usec = Thread_timeout * 1000;
//DUMP("calling select");
select(0, NULL, NULL, NULL, &timeout);
@@ -391,7 +391,10 @@ DUMP("this is the tick thread");
go through caml_handle_signal(), just record signal delivery via
caml_record_signal(). */
//fprintf(stderr, "Context %p: st_thread_tick: thread %p ticking.\n", ctx, (void*)pthread_self()); fflush(stderr);
+ DUMP("-- tick --");
+ /* DUMP("before caml_record_signal_r"); */
caml_record_signal_r(ctx, SIGPREEMPTION);
+ /* DUMP("after caml_record_signal_r"); */
//fprintf(stderr, "Context %p: st_thread_tick: thread %p ticked.\n", ctx, (void*)pthread_self()); fflush(stderr);
}
QR();
Oops, something went wrong.

0 comments on commit 4c6d7e8

Please sign in to comment.