Opened 17 years ago

Closed 15 years ago

Last modified 8 years ago

#12596 closed defect (fixed)

malformed variants can break registry

Reported by: david.reitter@… Owned by: mww@…
Priority: Normal Milestone: MacPorts 1.8.0
Component: base Version: 1.5.0
Keywords: Cc: kballard (Lily Ballard), jmroot (Joshua Root)
Port:

Description (last modified by ryandesign (Ryan Carsten Schmidt))

Beginning with a failed install of gcc43 on my (Intel) Macbook Pro (osx 10.4, current macports), I've been getting this error message when doing various things:

$ sudo port installed
Error: port installed failed: list must have an even number of elements
No ports are installed.

I have done "sudo port sync", to no avail.
"outdated" brings up the same message.

I have also tried to reinstall Macports from the release DMG (I still get the above message), only to discover that this has broken more things (i'll file a bug should i conclude it is one.)

Attachments (1)

receipt_flat.tcl.patch (559 bytes) - added by chris@… 16 years ago.
Error reporting patch for receipt_flat.tcl

Download all attachments as: .zip

Change History (17)

comment:1 Changed 17 years ago by mww@…

Cc: eridius@… mww@… added
Owner: changed from macports-dev@… to mww@…
Status: newassigned

I get this error, too - when doing livecheck on gcc43 and (on a different machine) when trying to activate gcc43.

Does someone know where this error originates from? (I'd really love to have this one more verbosive)

comment:2 Changed 17 years ago by david.reitter@…

The following might give you more information. (Looks similar for port -d outdated.)

The problem is that this doesn't just happen when installing gcc43 -- it also seems to be a permanent thing!

 sudo port -d installed
DEBUG: list must have an even number of elements
    while executing
"array set receipt_$ref $receipt_contents"
    (procedure "receipt_flat::open_entry" line 84)
    invoked from within
"${macports::registry.format}::open_entry $name $version $revision $variants"
    (procedure "open_entry" line 4)
    invoked from within
"open_entry $iname $iversion $irevision $ivariants"
    (procedure "registry::installed" line 13)
    invoked from within
"registry::installed"
Error: port installed failed: list must have an even number of elements
No ports are installed.
Last edited 8 years ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

comment:3 Changed 17 years ago by chas@…

i encountered same error. tried installing gcc43 which ended which ended with

DEBUG: installing file: /opt/local/var/macports/software/gcc43/4.3-20070907_0+darwin_8/opt/local/share/man/man1/gcov-mp-4.3.1.gz
list must have an even number of elements
Warning: the following items did not execute (for gcc43): org.macports.activate
Error: Status 1 encountered during processing.

port -d sync does not fix the problem. i still keep getting:

macbook:/opt/local root$  port -d installed
DEBUG: list must have an even number of elements
    while executing
"array set receipt_$ref $receipt_contents"
    (procedure "receipt_flat::open_entry" line 84)
    invoked from within
"${macports::registry.format}::open_entry $name $version $revision $variants"
    (procedure "open_entry" line 4)
    invoked from within
"open_entry $iname $iversion $irevision $ivariants"
    (procedure "registry::installed" line 13)
    invoked from within
"registry::installed"
Error: port installed failed: list must have an even number of elements
No ports are installed.

is there something i can do to manually correct this? hopefully something besides rm -rf /opt/local

comment:4 Changed 16 years ago by jmroot (Joshua Root)

Component: portsbase
Milestone: MacPorts base bugs

comment:5 Changed 16 years ago by jmroot (Joshua Root)

Cc: jmr@… added; mww@… removed

Is this the same as #12698?

comment:6 Changed 16 years ago by chris@…

It is not the same. I do not even have gcc43 installed, and I get the same error, with the same tcl traceback.

comment:7 Changed 16 years ago by jmroot (Joshua Root)

#12698 was caused by a malformed variant definition in the gcc43 portfile, so it's possible that other ports could have the same problem.

comment:8 Changed 16 years ago by chris@…

Good error reporting is invaluable. This isn't a fix, but it at least tells you what's causing the problem:

--- base/src/registry1.0/receipt_flat.tcl.orig       2008-10-13 23:34:15.000000000 -0400
+++ base/src/registry1.0/receipt_flat.tcl    2008-10-13 23:43:08.000000000 -0400
@@ -181,7 +181,9 @@
 
                # Remove any line starting with #
                while {[regexp "(^|\n)#.*\n(.*)\$" $receipt_contents match foo receipt_contents]} {}
-               array set receipt_$ref $receipt_contents
+               if { [catch {array set receipt_$ref $receipt_contents} rcpterr] } {
+                       error "Malformed package receipt for $name $version $revision $variants: $rcpterr"
+               }
        } else {
                # This is old Images format
Last edited 8 years ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

comment:9 Changed 16 years ago by chris@…

Bah. Check the attachments, and here's a format that's readable:

--- base/src/registry1.0/receipt_flat.tcl.orig       2008-10-13 23:34:15.000000000 -0400
+++ base/src/registry1.0/receipt_flat.tcl    2008-10-13 23:43:08.000000000 -0400
@@ -181,7 +181,9 @@
 
                # Remove any line starting with #
                while {[regexp "(^|\n)#.*\n(.*)\$" $receipt_contents match foo receipt_contents]} {}
-               array set receipt_$ref $receipt_contents
+               if { [catch {array set receipt_$ref $receipt_contents} rcpterr] } {
+                       error "Malformed package receipt for $name $version $revision $variants: $rcpterr"
+               }
        } else {
                # This is old Images format

Changed 16 years ago by chris@…

Attachment: receipt_flat.tcl.patch added

Error reporting patch for receipt_flat.tcl

comment:10 in reply to:  9 Changed 16 years ago by chris@…

Replying to chris@…:

A slightly better version, IMHO, as it points out that the problem stems back to a malformed Portfile:

--- base/src/receipt1.0/receipt_flat.tcl.orig   2008-10-13 23:34:15.000000000 -0400
+++ base/src/receipt1.0/receipt_flat.tcl        2008-10-13 23:54:53.000000000 -0400
@@ -181,7 +181,11 @@
 
                # Remove any line starting with #
                while {[regexp "(^|\n)#.*\n(.*)\$" $receipt_contents match foo receipt_contents]} {}
-               array set receipt_$ref $receipt_contents
+               if { [catch {array set receipt_$ref $receipt_contents} rcpterr] } {
+                       puts "Malformed package receipt for $name $version $revision $variants"
+                       puts "receipt_contents = '$receipt_contents'"
+                       error $rcpterr
+               }
        } else {
                # This is old Images format

The problem was an extra newline in the Portfile. There's no way I could have figured that out from the original error message.

comment:11 Changed 16 years ago by jmroot (Joshua Root)

Patch fails to apply to trunk, even with 'receipt1.0' changed to 'registry1.0'.

comment:12 Changed 15 years ago by tobypeterson

Milestone: MacPorts base bugsMacPorts Future

Milestone MacPorts base bugs deleted

comment:13 Changed 15 years ago by jmroot (Joshua Root)

Summary: "list must have an even number of elements"malformed variants can break registry

comment:14 Changed 15 years ago by jmroot (Joshua Root)

Applied a modified version of the error reporting patch in r44612. We still need to error out on malformed variants when parsing Portfiles.

comment:15 Changed 15 years ago by jmroot (Joshua Root)

Milestone: MacPorts FutureMacPorts 1.8.0
Resolution: fixed
Status: assignedclosed

Fixed in r50719.

comment:16 Changed 8 years ago by ryandesign (Ryan Carsten Schmidt)

Description: modified (diff)
Note: See TracTickets for help on using tickets.