Well, here goes a stupid patch. Just removes the fprintf to the stderr. If the function returns NULL on failure, callers should verify result.

Can't remember the name of someone who suggested right this. I just needed to look a little more to the code to be sure it was the right(??) thing to do.

Apply, or not, it :->

Cheers,
Alberto

Alberto Simões wrote:
Ok, more details on this bug...
on src/dynext.c...

PMC *Parrot_init_lib(Interp *interpreter,
                PMC *(*load_func)(Interp *),
                void (*init_func)(Interp *, PMC *))
{
    PMC *lib_pmc = NULL;

    fprintf(stderr, "Called..\n");

    if (load_func)
        lib_pmc = (*load_func)(interpreter);

    if (!load_func || !lib_pmc) {
        /* seems to be a native/NCI lib */
        [...]
        lib_pmc = pmc_new(interpreter, enum_class_ParrotLibrary);
    }

Basically, 'load_func' is true, but loading fails (twice, don't know why yet). Then, code enter in the second if, and it *seems* to work.

Now, if there are two different options to load the library, the code used to load it can't just write to stdout the error message.



Cheers
The newby-bug-hunter.

Alberto Simões wrote:
gdbmhash.pmc class_init is being called more than once... first time the load fails, second time it fails... and is not called any more. Something very weird around :)

Alberto Simões wrote:
It's me again. Linked with gdbm (compiled with fink) and got these errors.

They are kind weird because they complain about not being able to load the library, but the tests run correctly. If they run correctly without loading the library one of two things happens:
 1) the tests do not test the library
2) the error message should not be issued because the library is being loaded

Well, kind of :)

Cheers
Alberto



t/dynclass/gdbmhash............NOK 1
#     Failed test (t/dynclass/gdbmhash.t at line 43)
#          got: 'Couldn't load 'libgdbm': unknown reason
# Couldn't load 'libgdbm': unknown reason
# GDBMHash
# '
#     expected: 'GDBMHash
# '
t/dynclass/gdbmhash............NOK 2
#     Failed test (t/dynclass/gdbmhash.t at line 56)
#          got: 'Couldn't load 'libgdbm': unknown reason
# Couldn't load 'libgdbm': unknown reason
# 0
# 1
# 0
# '
#     expected: '0
# 1
# 0
# '
t/dynclass/gdbmhash............NOK 3
#     Failed test (t/dynclass/gdbmhash.t at line 76)
#          got: 'Couldn't load 'libgdbm': unknown reason
# Couldn't load 'libgdbm': unknown reason
# An unitialized GDBMHash has size 0.
# An GDBMHash for a new file has size 0.
# After one assignment GDBMHash has size 1.
# After two assignments GDBMHash has size 2.
# After 15 assignments GDBMHash has size 15.
# '
#     expected: 'An unitialized GDBMHash has size 0.
# An GDBMHash for a new file has size 0.
# After one assignment GDBMHash has size 1.
# After two assignments GDBMHash has size 2.
# After 15 assignments GDBMHash has size 15.
# '
t/dynclass/gdbmhash............NOK 4
#     Failed test (t/dynclass/gdbmhash.t at line 129)
#          got: 'Couldn't load 'libgdbm': unknown reason
# Couldn't load 'libgdbm': unknown reason
# An uninitialized GDBMHash is not.
# An GDBMHash for a new file is not.
# After one insert the GDBMHash is.
# '
#     expected: 'An uninitialized GDBMHash is not.
# An GDBMHash for a new file is not.
# After one insert the GDBMHash is.
# '
t/dynclass/gdbmhash............NOK 5
#     Failed test (t/dynclass/gdbmhash.t at line 161)
#          got: 'Couldn't load 'libgdbm': unknown reason
# Couldn't load 'libgdbm': unknown reason
# Wert urspruenglich
# Wert geaendert
# Wert nocheinmal geaendert
# Wert urspruenglich
# '
#     expected: 'Wert urspruenglich
# Wert geaendert
# Wert nocheinmal geaendert
# Wert urspruenglich
# '
t/dynclass/gdbmhash............NOK 6
#     Failed test (t/dynclass/gdbmhash.t at line 189)
#          got: 'Couldn't load 'libgdbm': unknown reason
# Couldn't load 'libgdbm': unknown reason
# 0
# 1
# 0
# 1
# '
#     expected: '0
# 1
# 0
# 1
# '
t/dynclass/gdbmhash............NOK 7
#     Failed test (t/dynclass/gdbmhash.t at line 223)
#          got: 'Couldn't load 'libgdbm': unknown reason
# Couldn't load 'libgdbm': unknown reason
# Wert
# Wert
# Wert
# Wert
# '
#     expected: 'Wert
# Wert
# Wert
# Wert
# '
t/dynclass/gdbmhash............NOK 8
#     Failed test (t/dynclass/gdbmhash.t at line 254)
#          got: 'Couldn't load 'libgdbm': unknown reason
# Couldn't load 'libgdbm': unknown reason
# Wert
# Wert
# Wert
# Wert
# '
#     expected: 'Wert
# Wert
# Wert
# Wert
# '
t/dynclass/gdbmhash............NOK 9
#     Failed test (t/dynclass/gdbmhash.t at line 288)
#          got: 'Couldn't load 'libgdbm': unknown reason
# Couldn't load 'libgdbm': unknown reason
# Wert
# Wert
# Wert
# Wert
# '
#     expected: 'Wert
# Wert
# Wert
# Wert
# '
t/dynclass/gdbmhash............NOK 10
#     Failed test (t/dynclass/gdbmhash.t at line 321)
#          got: 'Couldn't load 'libgdbm': unknown reason
# Couldn't load 'libgdbm': unknown reason
# Wert
# Wert
# Wert
# Wert
# '
#     expected: 'Wert
# Wert
# Wert
# Wert
# '
t/dynclass/gdbmhash............NOK 11
#     Failed test (t/dynclass/gdbmhash.t at line 358)
#          got: 'Couldn't load 'libgdbm': unknown reason
# Couldn't load 'libgdbm': unknown reason
# -11012005
# -11012005
# -11012005
# -11012005
# '
#     expected: '-11012005
# -11012005
# -11012005
# -11012005
# '
t/dynclass/gdbmhash............NOK 12
#     Failed test (t/dynclass/gdbmhash.t at line 393)
#          got: 'Couldn't load 'libgdbm': unknown reason
# Couldn't load 'libgdbm': unknown reason
# -1101.2
# -1101.2
# -1101.2
# -1101.2
# '
#     expected: '-1101.2
# -1101.2
# -1101.2
# -1101.2
# '
t/dynclass/gdbmhash............NOK 13
#     Failed test (t/dynclass/gdbmhash.t at line 428)
#          got: 'Couldn't load 'libgdbm': unknown reason
# Couldn't load 'libgdbm': unknown reason
# "a" exists: 0
# "a" exists: 1
# "a" exists: 0
# '
#     expected: '"a" exists: 0
# "a" exists: 1
# "a" exists: 0
# '
# Looks like you failed 13 tests of 13.
t/dynclass/gdbmhash............dubious
        Test returned status 13 (wstat 3328, 0xd00)
DIED. FAILED tests 1-13
        Failed 13/13 tests, 0.00% okay




--
Alberto Simões - Departamento de Informática - Universidade do Minho
                 Campus de Gualtar - 4710-057 Braga - Portugal
Index: src/dynext.c
===================================================================
--- src/dynext.c        (revision 9504)
+++ src/dynext.c        (working copy)
@@ -174,8 +174,6 @@
                 return path;
             }
             err = Parrot_dlerror();
-            fprintf(stderr, "Couldn't load '%s': %s\n",
-                    full_name, err ? err : "unknown reason");
             string_cstring_free(file_name);
             string_cstring_free(full_name);
             string_cstring_free(file_w_ext);
@@ -208,8 +206,6 @@
                     return path;
                 }
                 err = Parrot_dlerror();
-                fprintf(stderr, "Couldn't load '%s': %s\n",
-                        full_name, err ? err : "unknown reason");
                 string_cstring_free(file_name);
                 string_cstring_free(file_w_ext);
                 return NULL;
@@ -259,8 +255,6 @@
     }
 #endif
     err = Parrot_dlerror();
-    fprintf(stderr, "Couldn't load '%s': %s\n",
-            file_name, err ? err : "unknown reason");
     string_cstring_free(file_name);
     return NULL;
 }
@@ -310,8 +304,9 @@
          */
         lib_pmc = pmc_new(interpreter, enum_class_ParrotLibrary);
     }
+
     /*
-     *  call init, if it exists
+     *  Call init, if it exists
      */
     if (init_func)
         (init_func)(interpreter, lib_pmc);

Reply via email to