Gorm: SaveAfterAssociations panic: reflect.Value.Addr of unaddressable value

Created on 2 Mar 2015  路  6Comments  路  Source: go-gorm/gorm

Hi @jinzhu,

When trying your last fix for our Count issue (thanks for looking into this btw), have hit another one (have realized that we were running an older version on our test builds, so discovered it when upgrading).

Please let me know if we maybe need to change anything in our code maybe?

We got this in the commit:

commit 803343fbe5344d8e2816779461a270ec8e826c63
Author: Jinzhu <[email protected]>
Date:   Tue Feb 17 14:30:37 2015 +0800

    Fix scope.getField

Last good commit for us was:

 commit b8976ab20fe51b640587300830e3df42f2f095e6
Merge: b3b87d9 73b6f0e
Author: Jinzhu <[email protected]>
Date:   Tue Feb 17 08:34:09 2015 +0800

    Merge branch 'adamar-master'

Panic we are getting:

[2015-03-02 14:11:26]  
--- FAIL: TestImportToStorDb (0.08s)
panic: reflect.Value.Addr of unaddressable value [recovered]
    panic: reflect.Value.Addr of unaddressable value

goroutine 270 [running]:
testing.func路006()
    /usr/local/go/src/testing/testing.go:441 +0x181
reflect.Value.Addr(0xd28d00, 0xc208142d70, 0x59, 0x0, 0x0, 0x0)
    /usr/local/go/src/reflect/value.go:233 +0x91
github.com/cgrates/gorm.SaveAfterAssociations(0xc2084ea780)
    /usr/local/goapps/src/github.com/cgrates/gorm/callback_shared.go:110 +0x1ddf
github.com/cgrates/gorm.(*Scope).callCallbacks(0xc2084ea780, 0xc208065140, 0x8, 0x8, 0xc2082d1970)
    /usr/local/goapps/src/github.com/cgrates/gorm/scope_private.go:311 +0x6b
github.com/cgrates/gorm.(*DB).Save(0xc2084cadc0, 0xce2a20, 0xc208142d20, 0xc208142d20)
    /usr/local/goapps/src/github.com/cgrates/gorm/main.go:267 +0x15a
github.com/cgrates/cgrates/engine.(*SQLStorage).SetTPActionTimings(0xc208071970, 0xd930f0, 0x8, 0xc20845e570, 0x0, 0x0)
    /usr/local/goapps/src/github.com/cgrates/cgrates/engine/storage_sql.go:581 +0x496
github.com/cgrates/cgrates/engine.(*TPCSVImporter).importActionTimings(0xc20814e140, 0xc2080ddff0, 0xf, 0x0, 0x0)
    /usr/local/goapps/src/github.com/cgrates/cgrates/engine/tpimporter_csv.go:466 +0x324
github.com/cgrates/cgrates/engine.(*TPCSVImporter).Run(0xc20814e140, 0x0, 0x0)
    /usr/local/goapps/src/github.com/cgrates/cgrates/engine/tpimporter_csv.go:65 +0x1ce
github.com/cgrates/cgrates/engine.TestImportToStorDb(0xc208104f30)
    /usr/local/goapps/src/github.com/cgrates/cgrates/engine/loader_local_test.go:184 +0x1b7
testing.tRunner(0xc208104f30, 0x11b1650)
    /usr/local/go/src/testing/testing.go:447 +0xbf
created by testing.RunTests
    /usr/local/go/src/testing/testing.go:555 +0xa8b

goroutine 1 [chan receive]:
testing.RunTests(0xf3d770, 0x11b01e0, 0x189, 0x189, 0x11b3c01)
    /usr/local/go/src/testing/testing.go:556 +0xad6
testing.(*M).Run(0xc2080fbae0, 0x11be9e0)
    /usr/local/go/src/testing/testing.go:485 +0x6c
main.main()
    github.com/cgrates/cgrates/engine/_test/_testmain.go:878 +0x1d5

goroutine 260 [chan receive]:
database/sql.(*DB).connectionOpener(0xc20840db80)
    /usr/local/go/src/database/sql/sql.go:589 +0x4c
created by database/sql.Open
    /usr/local/go/src/database/sql/sql.go:452 +0x31c
exit status 2
FAIL    github.com/cgrates/cgrates/engine   0.670s

Thanks in advance!

DanB

Most helpful comment

Hello @danbogos

Could you write a sample code that could reproduce the issue?

I guess this is caused by you are not using pointer of struct in some place that should use that.

All 6 comments

Hello @danbogos

Could you write a sample code that could reproduce the issue?

I guess this is caused by you are not using pointer of struct in some place that should use that.

@jinzhu :
Many thanks for so fast feedback. You were right, we were calling the Save with the value and not the pointer, hence the issue with address. Corrected that on our side and now all smooth.

Thanks again!
DanB

thank both @danbogos @jinzhu

got it , thanks

thank you very much馃檪

save function must use pointer valuable.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

koalacxr picture koalacxr  路  3Comments

Quentin-M picture Quentin-M  路  3Comments

zeropool picture zeropool  路  3Comments

rfyiamcool picture rfyiamcool  路  3Comments

pjebs picture pjebs  路  3Comments