[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mysql-bugs
Subject:    Re: innodb segv on Tru64/alpha/cc in mach_read_from_2
From:       "Heikki Tuuri" <Heikki.Tuuri () innodb ! com>
Date:       2002-07-22 23:41:12
[Download RAW message or body]

Dan,

thank you for the excellent bug report! This is a major bug in all 64-bit
versions of InnoDB. The code for the SQL NULL should be 0xFFFFFFFF for the
storage to the undo log to work.

Updating a row so that a value changes from SQL NULL to something else, or
the other way around, will expose this bug. The bug will also appear if one
updates any indexed column in a row where some indexed column has the SQL
NULL value.

The patch below should fix the problem. We must use ULINT32_UNDEFINED as the
SQL NULL number code.

The fix will be in 3.23.52 and 4.0.3.

Best regards,

Heikki Tuuri
Innobase Oy

...............
ChangeSet
  1.1104 02/07/23 01:59:43 heikki@hundin.mysql.fi +1 -0
  univ.i:
    Fix a bug in the storage of the SQL NULL value in 64-bit computers: the
value code must fit in 32 bits

  innobase/include/univ.i
    1.22 02/07/23 01:59:31 heikki@hundin.mysql.fi +6 -2
    Fix a bug in the storage of the SQL NULL value in 64-bit computers: the
value code must fit in 32 bits

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: heikki
# Host: hundin.mysql.fi
# Root: /home/heikki/mysql3

--- 1.21/innobase/include/univ.i Sat Jun 22 20:37:08 2002
+++ 1.22/innobase/include/univ.i Tue Jul 23 01:59:31 2002
@@ -204,8 +204,12 @@
 #endif

 /* The following number as the length of a logical field means that the
field
-has the SQL NULL as its value. */
-#define UNIV_SQL_NULL ULINT_UNDEFINED
+has the SQL NULL as its value. NOTE that because we assume that the length
+of a field is a 32-bit integer when we store it, for example, to an undo
log
+on disk, we must have also this number fit in 32 bits, also in 64-bit
+computers! */
+
+#define UNIV_SQL_NULL ULINT32_UNDEFINED

 /* Lengths which are not UNIV_SQL_NULL, but bigger than the following
 number indicate that a field contains a reference to an externally


......................
>Description:
I'm trying to use innodb tables with rt 2.0.14, and mysqld is segving
in mach_read_from_2; the traceback looks like:

(ladebug) where
>0  0x120273cf0 in mach_read_from_2(b=0x2401d02c6)
"../include/mach0data.ic":66
#1  0x12021c7ac in trx_undo_rec_get_partial_row(ptr=0x2401d02c6,
index=0x14024d8a8,
row=0x1401d0a28, heap=0x1401d0238) "trx0rec.c":939
#2  0x1201e8a70 in row_purge_parse_undo_rec(node=0x1401d08a8,
updated_extern=0x1425d1980,
thr=0x1401d05d0) "row0purge.c":524
#3  0x1201e8b30 in row_purge(node=0x1401d08a8, thr=0x1401d05d0)
"row0purge.c":566
#4  0x1201e8c50 in row_purge_step(thr=0x1401d05d0) "row0purge.c":620
#5  0x1201d0e44 in que_thr_step(thr=0x1401d05d0) "que0que.c":1305
#6  0x1201d118c in que_run_threads(thr=0x1401d05d0) "que0que.c":1459
#7  0x120214700 in trx_purge() "trx0purge.c":1065
#8  0x1201ba73c in srv_master_thread(arg=0x0) "srv0srv.c":2607
#9  0x3ff805b4e4c in __thdBase(0x2401d02c6, 0x1b, 0x1401d0240, 0x140285046,
0x3,
0x30) in /usr/shlib/libpthread.so

The value of ptr passed to trx_undo_rec_get_partial_row, 0x2401d02c6,
is approximately 0x100000000 from where a reasonable pointer should
be.  Further debugging shows that the value is incorrectly incremented
in trx_undo_rec_get_col_val:

[2] stopped at [unsigned char* trx_undo_update_rec_get_update(unsigned
char*, dict_index_t*,
ulint, dulint, dulint, ulint, mem_heap_t*, upd_t**):877 0x12021c568]
    877                 ptr = trx_undo_rec_get_col_val(ptr, &field, &len);
(ladebug) p ptr
0x1401d02c2="\360\377\377\377\377"
(ladebug) s
stopped at [unsigned char* trx_undo_rec_get_col_val(unsigned char*, unsigned
char**,
ulint*):342 0x12021b278]
    342         *len = mach_read_compressed(ptr);
(ladebug) n
stopped at [unsigned char* trx_undo_rec_get_col_val(unsigned char*, unsigned
char**,
ulint*):343 0x12021b290]
    343         ptr += mach_get_compressed_size(*len);
(ladebug) p *len
4294967295
(ladebug) n
stopped at [unsigned char* trx_undo_rec_get_col_val(unsigned char*, unsigned
char**,
ulint*):345 0x12021b2a8]
    345         *field = ptr;
(ladebug) p ptr
0x1401d02c7=""
(ladebug) n
stopped at [unsigned char* trx_undo_rec_get_col_val(unsigned char*, unsigned
char**,
ulint*):347 0x12021b2b0]
    347         if (*len != UNIV_SQL_NULL) {
(ladebug) p ptr
0x1401d02c7=""
(ladebug) n
stopped at [unsigned char* trx_undo_rec_get_col_val(unsigned char*, unsigned
char**,
ulint*):348 0x12021b2bc]
    348                 if (*len >= UNIV_EXTERN_STORAGE_FIELD) {
(ladebug) n
stopped at [unsigned char* trx_undo_rec_get_col_val(unsigned char*, unsigned
char**,
ulint*):351 0x12021b2dc]
    351                         ptr += *len;
(ladebug) n
stopped at [unsigned char* trx_undo_rec_get_col_val(unsigned char*, unsigned
char**,
ulint*):355 0x12021b2e4]
    355         return(ptr);
(ladebug) p *len
4294967295
(ladebug) p ptr
0x2401d02c6

I believe the bug is, at least superficially, in the test

 if (*len != UNIV_SQL_NULL) {

on line 347 of tx0rec.c -- *len is from mach_read_compressed(ptr),
which at most reads 4 bytes, but on a system where long is 64 bits,
UNIV_SQL_NULL is 8 bytes of 0xff -- hence that test can never trigger.

I have not tried compiling with gcc -- if it doesn't crash compiled
with gcc, there must be a bogus sign extension somewhere in gcc (I say
bogus because it looks like everything is uniformly unsigned).

>How-To-Repeat:
On a Tru64 system (possibly other systems where sizeof(long) > 4),
with innodb compiled in, load the following (if the long lines are a
problem, I can put this on our web site):

-- MySQL dump 8.21
--
-- Host: localhost    Database: rt2
---------------------------------------------------------
-- Server version 3.23.51-log

--
-- Table structure for table 'Attachments'
--

DROP TABLE IF EXISTS Attachments;
CREATE TABLE Attachments (
  id int(11) NOT NULL auto_increment,
  TransactionId int(11) NOT NULL default '0',
  Parent int(11) default NULL,
  MessageId varchar(160) default NULL,
  Subject varchar(255) default NULL,
  Filename varchar(255) default NULL,
  ContentType varchar(80) default NULL,
  ContentEncoding varchar(80) default NULL,
  Content longtext,
  Headers longtext,
  Creator int(11) default NULL,
  Created datetime default NULL,
  PRIMARY KEY  (id),
  KEY Attachments1 (Parent),
  KEY Attachments2 (TransactionId),
  KEY Attachments3 (Parent,TransactionId)
) TYPE=InnoDB;

/*!40000 ALTER TABLE Attachments DISABLE KEYS */;

--
-- Dumping data for table 'Attachments'
--


LOCK TABLES Attachments WRITE;
INSERT INTO Attachments VALUES (1,1,0,NULL,'test
message',NULL,'text/plain','none','setting
up rt...\n','Received: from lnscu5.lns.cornell.edu (lnscu5.lns.cornell.edu
[128.84.44.111])
by lnscu4.lns.cornell.edu (8.9.3/8.9.3) with ESMTP id RAA24885 for
<rt@lnscu4.lns.cornell.edu>;
Sun, 21 Jul 2002 17:29:15 -0400 (EDT)\nReceived: from lnxcu9.lns.cornell.edu
(lnxcu9.lns.cornell.edu
[128.84.46.100]) by lnscu5.lns.cornell.edu (8.12.1/8.12.2) with ESMTP id
g6LLTFUr024301
for <rt@www.lns.cornell.edu>; Sun, 21 Jul 2002 17:29:15 -0400
(EDT)\nReceived: from
lnxcu9.lns.cornell.edu (dsr@localhost) by lnxcu9.lns.cornell.edu
(8.11.6/8.8.8)
with ESMTP id g6LLTFY16292 for <rt@www.lns.cornell.edu>; Sun, 21 Jul 2002
17:29:15
-0400\nMessage-Id:
<200207212129.g6LLTFY16292@lnxcu9.lns.cornell.edu>\nX-Authentication-Warning
:
lnxcu9.lns.cornell.edu: dsr owned process doing -bs\nTo:
rt@lnscu4.lns.cornell.edu\nSubject:
test message\nDate: Sun, 21 Jul 2002 17:29:15 -0400\nFrom: Dan Riley
<dsr@mail.lns.!
cornell.edu>\n',5,'2002-07-21 21:29:19');

/*!40000 ALTER TABLE Attachments ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table 'Tickets'
--

DROP TABLE IF EXISTS Tickets;
CREATE TABLE Tickets (
  id int(11) NOT NULL auto_increment,
  EffectiveId int(11) default NULL,
  Queue int(11) default NULL,
  Type varchar(16) default NULL,
  IssueStatement int(11) default NULL,
  Resolution int(11) default NULL,
  Owner int(11) default NULL,
  Subject varchar(200) default '[no subject]',
  InitialPriority int(11) default NULL,
  FinalPriority int(11) default NULL,
  Priority int(11) default NULL,
  Status varchar(10) default NULL,
  TimeWorked int(11) default NULL,
  TimeLeft int(11) default NULL,
  Told datetime default NULL,
  Starts datetime default NULL,
  Started datetime default NULL,
  Due datetime default NULL,
  Resolved datetime default NULL,
  LastUpdatedBy int(11) default NULL,
  LastUpdated datetime default NULL,
  Creator int(11) default NULL,
  Created datetime default NULL,
  Disabled smallint(6) NOT NULL default '0',
  PRIMARY KEY  (id),
  KEY Tickets1 (Queue,Status),
  KEY Tickets2 (Owner),
  KEY Tickets3 (EffectiveId),
  KEY Tickets4 (id,Status),
  KEY Tickets5 (id,EffectiveId)
) TYPE=InnoDB;

/*!40000 ALTER TABLE Tickets DISABLE KEYS */;

--
-- Dumping data for table 'Tickets'
--


LOCK TABLES Tickets WRITE;
INSERT INTO Tickets VALUES (1,1,1,'ticket',NULL,NULL,2,'test
message',0,0,0,'new',0,0,NULL,'1970-01-01
00:00:00',NULL,'2002-07-21 21:29:19',NULL,5,'2002-07-21
21:29:20',5,'2002-07-21
21:29:19',0);

/*!40000 ALTER TABLE Tickets ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table 'Transactions'
--

DROP TABLE IF EXISTS Transactions;
CREATE TABLE Transactions (
  id int(11) NOT NULL auto_increment,
  EffectiveTicket int(11) default NULL,
  Ticket int(11) default NULL,
  TimeTaken int(11) default NULL,
  Type varchar(20) default NULL,
  Field varchar(40) default NULL,
  OldValue varchar(255) default NULL,
  NewValue varchar(255) default NULL,
  Data varchar(100) default NULL,
  Creator int(11) default NULL,
  Created datetime default NULL,
  PRIMARY KEY  (id),
  KEY Transactions1 (Ticket),
  KEY Transactions2 (EffectiveTicket)
) TYPE=InnoDB;

/*!40000 ALTER TABLE Transactions DISABLE KEYS */;

--
-- Dumping data for table 'Transactions'
--


LOCK TABLES Transactions WRITE;
INSERT INTO Transactions VALUES
(1,NULL,1,0,'Create',NULL,NULL,NULL,NULL,5,'2002-07-21
21:29:19');

/*!40000 ALTER TABLE Transactions ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table 'Watchers'
--

DROP TABLE IF EXISTS Watchers;
CREATE TABLE Watchers (
  id int(11) NOT NULL auto_increment,
  Type varchar(16) default NULL,
  Scope varchar(16) default NULL,
  Value int(11) default NULL,
  Email varchar(255) default NULL,
  Quiet int(11) default NULL,
  Owner int(11) default NULL,
  Creator int(11) default NULL,
  Created datetime default NULL,
  LastUpdatedBy int(11) default NULL,
  LastUpdated datetime default NULL,
  PRIMARY KEY  (id),
  KEY Watchers1 (Scope,Value,Type,Owner)
) TYPE=InnoDB;

/*!40000 ALTER TABLE Watchers DISABLE KEYS */;

--
-- Dumping data for table 'Watchers'
--


LOCK TABLES Watchers WRITE;
INSERT INTO Watchers VALUES (1,'AdminCc','Queue',6,NULL,0,5,3,'2002-07-21
21:13:52',3,'2002-07-21
21:13:52'),(2,'Requestor','Ticket',1,NULL,0,5,5,'2002-07-21
21:29:19',5,'2002-07-21
21:29:19');

/*!40000 ALTER TABLE Watchers ENABLE KEYS */;
UNLOCK TABLES;

INSERT INTO Tickets (Creator, Due, Status, LastUpdatedBy, Resolved, Type,
TimeWorked,
LastUpdated, Subject, Queue, FinalPriority, TimeLeft, InitialPriority,
Owner, Created,
Priority, Starts) VALUES ('5', '2002-07-22 18:39:59', 'new', '5', NULL,
'ticket',
'0', '2002-07-22 18:39:59', 'testing patch', '1', 0, 0, 0, '2', '2002-07-22
18:39:59',
0, '1970-01-01 00:00:00');
UPDATE Tickets SET EffectiveId='2' WHERE id='2';
INSERT INTO Watchers (Creator, LastUpdatedBy, Scope, Type, LastUpdated,
Quiet, Value,
Created, Owner, Email) VALUES ('5', '5', 'Ticket', 'Requestor', '2002-07-22
18:39:59',
0, '2', '2002-07-22 18:39:59', 5, NULL);
INSERT INTO Transactions (Creator, OldValue, Ticket, Data, Type, TimeTaken,
NewValue,
Field, Created) VALUES ('5', NULL, '2', NULL, 'Create', 0, NULL, NULL,
'2002-07-22
18:39:59');
INSERT INTO Attachments (Creator, ContentEncoding, Filename, TransactionId,
Headers,
ContentType, Subject, Content, Created, Parent) VALUES ('5', 'none', NULL,
2, 'Received:
from lnscu5.lns.cornell.edu (lnscu5.lns.cornell.edu [128.84.44.111]) by
lnscu4.lns.cornell.edu
(8.9.3/8.9.3) with ESMTP id OAA22308 for <rt@lnscu4.lns.cornell.edu>; Mon,
22 Jul
2002 14:39:55 -0400 (EDT)\nReceived: from mail.lns.cornell.edu
(lnxcu9.lns.cornell.edu
[128.84.46.100]) by lnscu5.lns.cornell.edu (8.12.1/8.12.2) with ESMTP id
g6MIdsUr010316
for <rt@lnscu4.lns.cornell.edu>; Mon, 22 Jul 2002 14:39:55 -0400
(EDT)\nMessage-Id:
<3D3C517A.8010806@mail.lns.cornell.edu>\nDate: Mon, 22 Jul 2002
14:39:54 -0400\nFrom:
Dan Riley <dsr@mail.lns.cornell.edu>\nUser-Agent: Mozilla/5.0 (X11; U; Linux
i686;
en-US; rv:1.0rc3) Gecko/20020523\nX-Accept-Language: en-us,
en\nMIME-Version: 1.0\nTo:
general <rt@lnscu4.lns.cornell.edu>\nSubject: testing patch\nContent-Type:
text/plain;
charset=us-ascii; format=flowed\nCon!
tent-Transfer-Encoding: 7bit\n', 'text/plain', 'testing patch', 'will innodb
crash?\n\n',
'2002-07-22 18:39:59', 0);


>Fix:

Changing UNIV_SQL_NULL to ULINT32_UNDEFINED in the line referenced
above appears (in very light testing) to avoid the crash; I have not
otherwise tested it for correctness.

>Submitter-Id: <submitter ID>
>Originator:
>Organization: LEPP, Cornell University
>
>MySQL support: none
>Synopsis: innodb crashes on Tru64/alpha in mach_read_from_2
>Severity: serious
>Priority: medium
>Category: mysql
>Class:  sw-bug
>Release: mysql-3.23.51 (Source distribution)
>Server: /usr/local/bin/mysqladmin  Ver 8.23 Distrib 3.23.49, for
dec-osf4.0f on
alphaev56
Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license

(Note: the 3.23.49 is incorrect--there were multiple mysqlds running
while I was debugging this w/3.23.51)

Server version  3.23.49-log
Protocol version 10
Connection  Localhost via UNIX socket
UNIX socket  /tmp/mysql.sock
Uptime:   42 sec

Threads: 2  Questions: 92  Slow queries: 0  Opens: 20  Flush tables: 1  Open
tables:
14 Queries per second avg: 2.190
>Environment:

System: OSF1 lnscu4.lns.cornell.edu V4.0 1229 alpha
Machine: alpha
Some paths:  /usr/local/bin/perl /usr/local/bin/make /usr/local/bin/gmake
/usr/local/bin/gcc
/usr/bin/cc
GCC: Reading specs from
/usr/local/lib/gcc-lib/alpha-dec-osf4.0f/2.95.2/specs
gcc version 2.95.2 19991024 (release)
Compilation info: CC='cc -std -pthread'  CFLAGS='-g'  CXX='cxx -pthread'
CXXFLAGS='-g'
 LDFLAGS=''
LIBC:
lrwxr-xr-x   1 root     system         17 Dec 16  1999 /lib/libc.a ->
../ccs/lib/libc.a
lrwxr-xr-x   1 root     system         17 Dec 16  1999 /usr/lib/libc.a ->
../ccs/lib/libc.a
Configure command:
./configure --with-mysqld-user=msql --without-bench --with-innodb
'CC=cc -std -pthread' CFLAGS=-g CXXFLAGS=-g 'CXX=cxx -pthread'




---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail bugs-thread12212@lists.mysql.com
To unsubscribe, e-mail <bugs-unsubscribe@lists.mysql.com>

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic