NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/51533: SQLite3 broken on armeb



>Number:         51533
>Category:       lib
>Synopsis:       SQLite3 broken on armeb
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Oct 06 10:55:00 +0000 2016
>Originator:     Rin Okuyama
>Release:        7.99.39
>Organization:
Faculty of Science and Technology, Keio University
>Environment:
NetBSD cubietruck 7.99.39 NetBSD 7.99.39 (CT) #0: Thu Oct  6 02:37:54 JST 2016  rin@XXX:XXX evbarm
>Description:
SQLite3 is broken on armeb as it assumes little endian for arm. As a
result, segmentation faults occur for makemandb(8), with /var/db/man.db
being broken:

  # uname -mpr
  7.99.39 evbarm earmv7hfeb
  # makemandb -f
  Memory fault
  # file /var/db/man.db
  /var/db/man.db: SQLite 3.x database, user version -1157418239

Note that it should be as follows:

  # file /var/db/man.db
  /var/db/man.db: SQLite 3.x database, user version 20120507
>How-To-Repeat:
Described above.
>Fix:
Include <sys/endian.h> to determine the byte order. I would thank
ryo@ for his useful comments.

--- src/external/public-domain/sqlite/Makefile.inc.orig	2016-10-06 05:16:48.174392631 +0900
+++ src/external/public-domain/sqlite/Makefile.inc	2016-10-06 05:17:10.060172040 +0900
@@ -14,6 +14,7 @@
 		-DHAVE_STDINT_H=1 \
 		-DHAVE_STRERROR_R=1 \
 		-DHAVE_USLEEP=1 \
+		-DHAVE_SYS_ENDIAN_H=1 \
 		-DSQLITE_ENABLE_COLUMN_METADATA \
 		-DSQLITE_ENABLE_FTS3_PARENTHESIS \
 		-DSQLITE_ENABLE_FTS4 \
--- src/external/public-domain/sqlite/dist/sqlite3.c.orig	2016-10-06 05:06:52.552267967 +0900
+++ src/external/public-domain/sqlite/dist/sqlite3.c	2016-10-06 05:52:00.781325015 +0900
@@ -11567,23 +11567,31 @@
 ** -DSQLITE_RUNTIME_BYTEORDER=1 is set, then byte-order is determined
 ** at run-time.
 */
-#if (defined(i386)     || defined(__i386__)   || defined(_M_IX86) ||    \
+#if defined(HAVE_SYS_ENDIAN_H) && !defined(SQLITE_RUNTIME_BYTEORDER)
+# include <sys/endian.h>
+# define SQLITE_BYTEORDER _BYTE_ORDER
+#elif (defined(i386)   || defined(__i386__)   || defined(_M_IX86) ||    \
      defined(__x86_64) || defined(__x86_64__) || defined(_M_X64)  ||    \
      defined(_M_AMD64) || defined(_M_ARM)     || defined(__x86)   ||    \
      defined(__arm__)) && !defined(SQLITE_RUNTIME_BYTEORDER)
 # define SQLITE_BYTEORDER    1234
-# define SQLITE_BIGENDIAN    0
-# define SQLITE_LITTLEENDIAN 1
-# define SQLITE_UTF16NATIVE  SQLITE_UTF16LE
-#endif
-#if (defined(sparc)    || defined(__ppc__))  \
+#elif (defined(sparc)  || defined(__ppc__))  \
     && !defined(SQLITE_RUNTIME_BYTEORDER)
 # define SQLITE_BYTEORDER    4321
-# define SQLITE_BIGENDIAN    1
-# define SQLITE_LITTLEENDIAN 0
-# define SQLITE_UTF16NATIVE  SQLITE_UTF16BE
 #endif
-#if !defined(SQLITE_BYTEORDER)
+#ifdef SQLITE_BYTEORDER
+# if   SQLITE_BYTEORDER == 1234
+#  define SQLITE_BIGENDIAN    0
+#  define SQLITE_LITTLEENDIAN 1
+#  define SQLITE_UTF16NATIVE  SQLITE_UTF16LE
+# elif SQLITE_BYTEORDER == 4321
+#  define SQLITE_BIGENDIAN    1
+#  define SQLITE_LITTLEENDIAN 0
+#  define SQLITE_UTF16NATIVE  SQLITE_UTF16BE
+# else
+#  error "Unknown byte order."
+# endif
+#else
 # ifdef SQLITE_AMALGAMATION
   const int sqlite3one = 1;
 # else



Home | Main Index | Thread Index | Old Index