roxen.lists.pike.general

Subject Author Date
The plot thickens (Re: Identifier reference index 36 out of range 0..29 (Re: Pike 7.8.306 beta)) Stephen R. van den Berg <srb[at]cuci[dot]nl> 22-06-2009
Stephen R. van den Berg wrote:
>Henrik Grubbstr?m wrote:
>>>Identifier reference index 36 out of range 0..29
>>>Identifier reference index 36 out of range 0..29

It bears some resemblance to a Heisenbug...
Adding more diagnostics makes the behaviour shift (maybe calling fprintf
or adding werror to destroy() breaks the (threading)code, not sure).
Now I get this:

15:36:48  : Loading font handlers ...
 0m 1.0s  :     Builtin fonts (scalable)
          :     Compact image file font (bitmap)
          :     FreeType fonts (scalable)
          :     Image directory fonts (bitmap)
          :     Image TAR-file fonts (bitmap)
15:36:48  :     Compatibility bitmap fonts (bitmap)
 0m 1.0s  : Done [30.2ms]
          : Adding languages ... Done [6.55ms]
          : Initiating argument cache ... SRB mysql init
Done [1.27ms]
SRB mysql init
Identifier reference index 263 out of range 0..36
/data/src/gpike/src/modules/Mysql/mysql.c:692: Fatal error:
Threads allowed from a different thread while threads are disabled. (self:
b7eb06c0, disabler: 0)

Whereas mysql.c:692 points at the MYSQL_ALLOW() in:
      if (mysql) {
        const char *info;
        MYSQL_ALLOW();
        info = mysql_get_host_info(mysql);

And I use the following debugging code:
diff --git a/lib/modules/Sql.pmod/mysql.pike b/lib/modules/Sql.pmod/mysql.pike
index ee219d1..fdc0929 100644
--- a/lib/modules/Sql.pmod/mysql.pike
+++ b/lib/modules/Sql.pmod/mysql.pike
@@ -848,6 +848,12 @@ protected void create(string|void host, string|void
database,
   }
 }
 
+//srb
+void destroy()
+{
+  werror("SRB mysql destroy() %O\n",(backtrace()));
+}
+
 #else
 constant this_program_does_not_exist=1;
 #endif /* constant(Mysql.mysql) */
diff --git a/src/modules/Mysql/mysql.c b/src/modules/Mysql/mysql.c
index 2a5ea2b..e9f6f0f 100644
--- a/src/modules/Mysql/mysql.c
+++ b/src/modules/Mysql/mysql.c
@@ -181,6 +181,7 @@ static MUTEX_T stupid_port_lock;
 
 static void init_mysql_struct(struct object *o)
 {
+fprintf(stderr,"SRB mysql init\n");
   MEMSET(PIKE_MYSQL, 0, sizeof(struct precompiled_mysql));
   INIT_MYSQL_LOCK();
   PIKE_MYSQL->mysql = mysql_init(NULL);
@@ -193,6 +194,7 @@ static void exit_mysql_struct(struct object *o)
   MYSQL *mysql = PIKE_MYSQL->mysql;
 
   PIKE_MYSQL->mysql = NULL;
+fprintf(stderr,"SRB mysql exit\n");
 
   if (PIKE_MYSQL->password) {
     free_string(PIKE_MYSQL->password);
@@ -224,6 +226,7 @@ static void exit_mysql_struct(struct object *o)
   MYSQL_ALLOW();
 
   if (mysql) {
+fprintf(stderr,"SRB mysql close\n");
     mysql_close(mysql);
   }
 
-- 
Sincerely,
           Stephen R. van den Berg.

"Very funny, Mr. Scott. Now beam down my clothes!"