anse1 / emacs-libpq

An Emacs 25 module for accessing postgres via libpq.
GNU General Public License v3.0
22 stars 4 forks source link

Could you help me? Emacs Bug: Invalid datatype (0x01) #9

Closed gnusupport closed 5 years ago

gnusupport commented 5 years ago
(defun rcd-sql (sql)
  (pq:query *rcd-pg* sql))

(rcd-sql "SELECT a.attname, pg_catalog.format_type(a.atttypid, a.atttypmod), (SELECT substring(pg_catalog.pg_get_expr(d.adbin, d.adrelid) for 128) FROM pg_catalog.pg_attrdef d WHERE d.adrelid = a.attrelid AND d.adnum = a.attnum AND a.atthasdef), a.attnotnull, a.attnum, (SELECT c.collname FROM pg_catalog.pg_collation c, pg_catalog.pg_type t WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation) AS attcollation, a.attidentity, NULL AS indexdef, NULL AS attfdwoptions, a.attstorage, CASE WHEN a.attstattarget=-1 THEN NULL ELSE a.attstattarget END AS attstattarget, pg_catalog.col_description(a.attrelid, a.attnum) FROM pg_catalog.pg_attribute a WHERE a.attrelid = '33748' AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum")

(["tlds_id" "integer" "nextval('tlds_tlds_id_seq'::regclass)" "" 1 #<EMACS BUG: INVALID DATATYPE (0x01) Save your buffers immediately and please report this bug> "" #<EMACS BUG: INVALID DATATYPE (0x01) Save your buffers immediately and please report this bug> #<EMACS BUG: INVALID DATATYPE (0x01) Save your buffers immediately and please report this bug> "p" #<EMACS BUG: INVALID DATATYPE (0x01) Save your buffers immediately and please report this bug> "ID"] ["tlds_tld" "text" #<EMACS BUG: INVALID DATATYPE (0x01) Save your buffers immediately and please report this bug> "" 2 #<EMACS BUG: INVALID DATATYPE (0x01) Save your buffers immediately and please report this bug> "" #<EMACS BUG: INVALID DATATYPE (0x01) Save your buffers immediately and please report this bug> #<EMACS BUG: INVALID DATATYPE (0x01) Save your buffers immediately and please report this bug> "x" #<EMACS BUG: INVALID DATATYPE (0x01) Save your buffers immediately and please report this bug> "TLD"] ["tlds_nic" "integer" #<EMACS BUG: INVALID DATATYPE (0x01) Save your buffers immediately and please report this bug> #<EMACS BUG: INVALID DATATYPE (0x01) Save your buffers immediately and please report this bug> 3 #<EMACS BUG: INVALID DATATYPE (0x01) Save your buffers immediately and please report this bug> "" #<EMACS BUG: INVALID DATATYPE (0x01) Save your buffers immediately and please report this bug> #<EMACS BUG: INVALID DATATYPE (0x01) Save your buffers immediately and please report this bug> "p" #<EMACS BUG: INVALID DATATYPE (0x01) Save your buffers immediately and please report this bug> "NIC Company"] ["tlds_description" "text" #<EMACS BUG: INVALID DATATYPE (0x01) Save your buffers immediately and please report this bug> #<EMACS BUG: INVALID DATATYPE (0x01) Save your buffers immediately and please report this bug> 4 #<EMACS BUG: INVALID DATATYPE (0x01) Save your buffers immediately and please report this bug> "" #<EMACS BUG: INVALID DATATYPE (0x01) Save your buffers immediately and please report this bug> #<EMACS BUG: INVALID DATATYPE (0x01) Save your buffers immediately and please report this bug> "x" #<EMACS BUG: INVALID DATATYPE (0x01) Save your buffers immediately and please report this bug> "Description"] . #<EMACS BUG: INVALID DATATYPE (0x01) Save your buffers immediately and please report this bug>)

     attname      | format_type |               substring               | attnotnull | attnum | attcollation | attidentity | indexdef | attfdwoptions | attstorage | attstattarget | col_description 
------------------+-------------+---------------------------------------+------------+--------+--------------+-------------+----------+---------------+------------+---------------+-----------------
 tlds_id          | integer     | nextval('tlds_tlds_id_seq'::regclass) | t          |      1 |              |             |          |               | p          |               | ID
 tlds_tld         | text        |                                       | t          |      2 |              |             |          |               | x          |               | TLD
 tlds_nic         | integer     |                                       | f          |      3 |              |             |          |               | p          |               | NIC Company
 tlds_description | text        |                                       | f          |      4 |              |             |          |               | x          |               | Description
(4 rows)

Basically, I have git upgraded to newest development Emacs version. Recompiled your module which worked so well over last months. And now I cannot run it, as I am crashing whole emacs by the above SQL query.

Do you know maybe, do you have some clue, how to avoid the crash?
gnusupport commented 5 years ago

Now I find that problem appears even with "SELECT 1".

There is always same bug coming up. Do you have idea maybe?

anse1 commented 5 years ago

Thanks for the report, I can reproduce it with the latest emacs master. I don't see anything suspicious in emacs' change log wrt. the module interface at first glance. Running git-bisect on emacs now to find out more.

gnusupport commented 5 years ago

Thank you much.

Latest commit that works is a1c53d4294550380de76d6a6c4e29e9e8f6f9133 Date: Tue Apr 16 14:33:24 2019 -0700

One before that one that worked is e40f39bec34feeec893fb66625f19cc4663cd217 Date: Sun Apr 14 09:27:50 2019 -0600

somewhere in the middle from April 16th to near the present time, Emacs is segfault on loading of the module.

I am trying ti find commit closer to the present time that works well.

anse1 commented 5 years ago

git-bisect yielded the following, which includes some changes to the module interface. Taking a closer look at them now.

09d746dad36e4780d379f975a84b1b076da78c50 is the first bad commit
commit 09d746dad36e4780d379f975a84b1b076da78c50
Author: Eli Zaretskii <eliz@gnu.org>
Date:   Fri Mar 22 11:02:46 2019 +0300

    Revert "Revert "Revert "Rely on conservative stack scanning to find "emacs_value"s"""

    This reverts commit 093d3e78d21d3d6c718997368ef4b31f9884401c,
    which reverted ee7ad83f20903208404a84b58b7a478b62924570,
    which reverted 3eb93c07f7a60ac9ce8a16f10c3afd5a3a31243a.

:040000 040000 911b54468dc8d3889071ff44320a850edf47229d f252275a4e125c20402e7c686d73aeb6be476190 M src
:040000 040000 bd75dbaf17f1777bff74d16ad0998d7ab0d3534c a795cf9fb7e5ade1041a70e5190c7f9847912549 M test
bisect run success
gnusupport commented 5 years ago

From gnu-emacs-help mailing list, as suggested by Philipp Stephani, I did following if this can help, and it was done with the latest commit:

emacs --module-assertion
Emacs module assertion: Emacs value not found in 11 values of 1 environments
Fatal error 6: Aborted
Backtrace:
emacs[0x5039f2]
emacs[0x4176a5]
emacs[0x41788b]
emacs[0x418223]
emacs[0x58cb31]
emacs[0x58ef72]
/home/admin/Programming/git/emacs-libpq/pq.so(+0x14ed)[0x7fd9e35444ed]
Aborted
phst commented 5 years ago

The issue is most likely that https://github.com/anse1/emacs-libpq/blob/master/pq.c#L325-L326 puts local references into static variables, which is not allowed, see https://phst.eu/emacs-modules#value-lifetime.

anse1 commented 5 years ago

Philipp writes:

The issue is most likely that https://github.com/anse1/emacs-libpq/blob/master/pq.c#L325-L326 puts local references into static variables, which is not allowed, see https://phst.eu/emacs-modules#value-lifetime.

Thanks, after removing these static vars, the testsuite passes again with current emacs master at dbe81e16583.

717g301github: can you confirm the latest commit fixes the issue for you?

gnusupport commented 5 years ago

I confirm, it works well now again, just as it was. Thank you much for efforts. It means!