[Mono-devel-list] [patch]Better error reporting when loading unmanaged libraries
Denis Gervalle
dgl at softec.st
Tue May 18 15:58:05 EDT 2004
Paolo Molaro wrote:
>On 05/05/04 Denis Gervalle wrote:
>
>>However, this may advocate for a conditional usage of this new feature,
>
>
>Maybe enable it only when getenv("MONO_DEBUG") returns not NULL.
>
You are right. Gonzalo seems to have tryed himself to a small fix of
that kind in current CVS. Hopeless, it is sometimes useless since it
only report the last error seen, which is not always the more
interresting one in that case.
>>diff -ru mono-0.91-orig/mono/metadata/icall.c
mono-0.91/mono/metadata/icall.c
>>--- mono-0.91-orig/mono/metadata/icall.c 2004-05-04
21:51:24.000000000 +0200
>>+++ mono-0.91/mono/metadata/icall.c 2004-05-05 19:58:49.000000000 +0200
>>@@ -4847,6 +4847,7 @@
>> mono_exception_from_name_msg (mono_defaults.corlib, "System",
exc_class, exc_arg ) );
>> }
>> /* create the wrapper, too? */
>>+ g_free((gpointer)exc_arg); /* No need to keep the error, no wrapper
need it */
>
>
>It would be better to change the function signature and document that
>the string needs to be g_free()ed.
>
I agreed, but that is more complex than you thought, and moreover,
looking at this carefully, this part of the patch is buggy. Currently,
the function sometimes report const char, and sometimes not. That is
bad. In that matter, a better mono_mb_emit_exception would helps.
>
>>diff -ru mono-0.91-orig/mono/metadata/loader.c
mono-0.91/mono/metadata/loader.c
>>--- mono-0.91-orig/mono/metadata/loader.c 2004-04-15
16:51:58.000000000 +0200
>>+++ mono-0.91/mono/metadata/loader.c 2004-05-05 19:58:49.000000000 +0200
>>@@ -564,6 +564,7 @@
>> const char *orig_scope;
>> const char *new_scope;
>> char *full_name, *file_name;
>>+ gchar *error_array[7]={NULL,NULL,NULL,NULL,NULL,NULL,NULL};
>
>
>You could use a GString here and just g_string_append () the error
>messages: it makes the code cleaner and makes the memory management
>simpler.
>
That is an alternative, but it would have needed to manage the separator
manually. I am working on an alternate and more complete patch. This one
will also report the name of the library tried. This idea have been
suggested by Joshua Tauberer for completeness.
Thanks for your comments,
Denis Gervalle
SOFTEC sa
http://www.softec.st
More information about the Mono-devel-list
mailing list