Coder Social home page Coder Social logo

aligo's People

Contributors

andyone avatar dependabot[bot] avatar silves-xiang avatar zeripath avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

aligo's Issues

Invalid interface conversion

Bug report

System info:

  • aligo v2.1.3
  • Debian GNU/Linux 12 (bookworm)
  • Kernel 6.1.0-17-amd64
  • Go 1.22.0 X:arenas (linux/amd64)

Steps to reproduce:

  1. Create file arena.go with code
//go:build goexperiment.arenas

package limited_arena

import (
	"arena"
	"github.com/Inspirate789/alloc/internal/limited_arena/constants"
	"reflect"
	"sync"
	"sync/atomic"
	"unsafe"
)

// Arena implements a size limit on the arena.Arena
type Arena struct {
	arena *arena.Arena
	free  uintptr
}

type gcMetadata struct {
	lastMarkID           uint64
	cyclicallyReferenced bool
	referenceCount       int // founded references (not all)
	Finalized            atomic.Bool
}

type ObjectMetadata struct {
	sync.RWMutex
	Address  unsafe.Pointer
	typeInfo reflect.Type
	arena    *Arena
	gcMetadata
}
  1. execute command
aligo -s ObjectMetadata view .

Expected behavior:

I'm expecting to get the result of analyzing the structure ObjectMetadata.

Actual behavior:

I get a panic:

––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
 ▾ github.com/Inspirate789/alloc/internal/limited_arena
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––

  // arena.go:27 | Size: 88
  type ObjectMetadata struct {
panic: interface conversion: types.Sizes is *types.gcSizes, not *types.StdSizes

goroutine 1 [running]:
github.com/essentialkaos/aligo/v2/inspect.GetMaxAlign(...)
        /home/inspirate789/go/pkg/mod/github.com/essentialkaos/aligo/v2@v2.1.3/inspect/inspect.go:81
github.com/essentialkaos/aligo/v2/cli.printCurrentFieldsInfo({0xc00036e940, 0x5, 0xc00003fbb0?})
        /home/inspirate789/go/pkg/mod/github.com/essentialkaos/aligo/v2@v2.1.3/cli/render.go:278 +0x2e6
github.com/essentialkaos/aligo/v2/cli.printStructInfo(0xc0002615e0, 0x0)
        /home/inspirate789/go/pkg/mod/github.com/essentialkaos/aligo/v2@v2.1.3/cli/render.go:257 +0xad
github.com/essentialkaos/aligo/v2/cli.PrintStruct(0xc00033f9e0, {0xc00027d4a0, 0xe}, 0x0)
        /home/inspirate789/go/pkg/mod/github.com/essentialkaos/aligo/v2@v2.1.3/cli/render.go:66 +0xf9
github.com/essentialkaos/aligo/v2/cli.process({0xc00007e440, 0x2, 0x1?})
        /home/inspirate789/go/pkg/mod/github.com/essentialkaos/aligo/v2@v2.1.3/cli/cli.go:203 +0x391
github.com/essentialkaos/aligo/v2/cli.Run({0x0, 0x0}, {0xb34f60, 0x15a, 0x15a})
        /home/inspirate789/go/pkg/mod/github.com/essentialkaos/aligo/v2@v2.1.3/cli/cli.go:118 +0x631
main.main()
        /home/inspirate789/go/pkg/mod/github.com/essentialkaos/aligo/v2@v2.1.3/aligo.go:27 +0x36

Additional info:
Your source file inspect.go where the panic is happening:

package inspect

// ...

// GetMaxAlign returns MaxAlign
func GetMaxAlign() int64 {
	if Sizes == nil {
		return 8
	}

	return Sizes.(*types.StdSizes).MaxAlign
}

I think the problem might be caused by the fact that I'm using //go:build goexperiment.arenas, but it's not a good idea to convert interfaces so insecurely.

assertion failed

we are trying to use aligo in our project linter, but we face with this issue:

aligo --tags "" check ./...
panic: /opt/hostedtoolcache/go/1.20.7/x64/src/go/types/sizes.go:181: assertion failed

goroutine 1 [running]:
go/types.assert(0x18?)

the faild workflow

how can we fix it?

support for build tags

aligo fails with errors when some parts of the codebase are behind go build tags.

my codebase contains source files which are only included when run/compiled with the corresponding flag
(eg. go run -tags something ...) will include files with //go:build something at the top.

is there some way of passing these flags when executing aligo so that these source files are included?

Bug report

System info:

  • aligo 1.5.3
  • MacOS Monterey
  • Darwin Kernel Version 21.3.0
  • go version go1.19.1 darwin/amd64
  • GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin21)

Steps to reproduce:

  1. Add a build tag comment to the top of a source file (eg. //go:build something)
  2. Run aligo check ./... or aligo view ./...

Expected behavior:

This behaviour is expected, it would be ideal if the -tags CLI flag was supported so projects using build tags were supported.
eg. aligo -tags something check ./...

Actual behavior:

Errors are printed to the terminal such as undeclared name: XX & XX not declared by package YY

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.