Skip to content

cmd/compile: <autogenerated>:1: symbol listed multiple times for same type across multiple packages #31252

Closed
@abnerxc

Description

@abnerxc

Different packages and same struct function compile error

env

go version go1.12.1 windows/amd64

description

this problem happeded in version go1.12, my test in version go1.11 is ok. I think this is compile bug.
this file struct is very common in WEB MVC mode.

error

# github.com/abner-xu/gincms/router
duplicate "".(*IndexController).Index-fm.stkobj
<autogenerated>:1: symbol "".(*IndexController).Index-fm.stkobj listed multiple times

dirTree

img

code

main

func main() {
	router.RouterInit()
}

router

type HandlerFunc func(*string)

func RouterInit() {
	homeIndex := &home.IndexController{}
	GET(homeIndex.Index)
	adminIndex := &admin.IndexController{}
	GET(adminIndex.Index)
}
func GET(handlers ...HandlerFunc) {
	return
}

admin-IndexController

package admin

import "fmt"

type IndexController struct{}

func (this *IndexController) Index(m *string) {
	fmt.Println(&m)
}

home-IndexController

package home

import "fmt"

type IndexController struct{}

func (this *IndexController) Index(m *string) {
	fmt.Println(&m)
}

Activity

andybons

andybons commented on Apr 4, 2019

@andybons
Member

github.com/abner-xu/gincms does not appear to be available for inspection.

Could you outline exact steps to reproduce the failure?

added
WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.
on Apr 4, 2019
added this to the Unplanned milestone on Apr 4, 2019
changed the title [-]listed multiple times[/-] [+]cmd/compile: getting listed multiple times error[/+] on Apr 4, 2019
andybons

andybons commented on Apr 4, 2019

@andybons
andybons

andybons commented on Apr 4, 2019

@andybons
abnerxc

abnerxc commented on Apr 5, 2019

@abnerxc
Author

github.com/abner-xu/gincms this is directory in my local. I am using go mod create project

andybons

andybons commented on Apr 5, 2019

@andybons
Member

@Abner-Xu that repository isn't available publicly.

Please outline exact steps to take to recreate the problem.

abnerxc

abnerxc commented on Apr 8, 2019

@abnerxc
Author

@andybons Please use this repositories https://github.com/abner-xu/goweb.git

added
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
and removed
WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.
on Apr 8, 2019
agnivade

agnivade commented on Apr 8, 2019

@agnivade
Contributor

This seems to be a regression from 1.11. If the same type name is declared in multiple packages, it throws this error.

changed the title [-]cmd/compile: getting listed multiple times error[/-] [+]cmd/compile: <autogenerated>:1: symbol listed multiple times for same type across multiple packages[/+] on Apr 8, 2019

4 remaining items

randall77

randall77 commented on Apr 10, 2019

@randall77
Contributor

I have a fix.
The problem is the stack object generation code was always using the local package name for its symbol. Normally that doesn't matter, as we're only compiling functions in the local package. But for wrappers, the compiler generates functions which live in other packages. When there are two other packages with identical functions to wrap, the same name appears twice, and the compiler goes boom.

gopherbot

gopherbot commented on Apr 11, 2019

@gopherbot
Contributor

Change https://golang.org/cl/171464 mentions this issue: cmd/compile: use correct package name for stack object symbol

randall77

randall77 commented on Apr 11, 2019

@randall77
Contributor

@gopherbot please open a backport to 1.11.

gopherbot

gopherbot commented on Apr 11, 2019

@gopherbot
Contributor

Backport issue(s) opened: #31396 (for 1.11).

Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases.

cuonglm

cuonglm commented on Apr 11, 2019

@cuonglm
Member

@randall77 👍

Two places in CL are where I found when trying to fix this, but it's not clear to me what the different between lookup(fmt.Sprintf("%s.stkobj", fn.funcname())).Linksym() and Ctxt.Lookup(fn.Func.lsym.Name + ".stkobj")?

randall77

randall77 commented on Apr 11, 2019

@randall77
Contributor

@gopherbot please open a backport to 1.12.

randall77

randall77 commented on Apr 11, 2019

@randall77
Contributor

@cuonglm Yes, it's pretty cryptic. fn.funcname() is just the function name (without the package) and lookup finds that name in the current package being compiled. fn.Func.lsym.Name is the full name with package included.

This part of the compiler really needs better documentation. It confuses me every time I look at it also...

andybons

andybons commented on Apr 12, 2019

@andybons
Member

@randall77 sorry, you'll have to open a backport bug for 1.12 yourself (if you haven't already). This is a known bug.

locked and limited conversation to collaborators on Apr 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @andybons@agnivade@abnerxc@cuonglm@randall77

        Issue actions

          cmd/compile: <autogenerated>:1: symbol listed multiple times for same type across multiple packages · Issue #31252 · golang/go