Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception std_env_get_assert_format #943

Closed
avelure opened this issue Aug 12, 2024 · 7 comments
Closed

Exception std_env_get_assert_format #943

avelure opened this issue Aug 12, 2024 · 7 comments
Labels

Comments

@avelure
Copy link

avelure commented Aug 12, 2024

This one I'm not able to reduce to an MWE.
When I remove a reference to a signal that uses an enum from another package the exception occurs.
Then it disappears again when I remove all references to a UVVM "disable_log_msg" for a VVC.
I'm just working on reducing a testcase, so all these packages and enums has been used with nvc for years.
I'm using nvc 1.14-devel (1.13.0.r34.g1e0063fe) (Using LLVM 18.1.6) with msys clang64

*****************************************************************************************************
 This is a *** LICENSED PRODUCT *** as given in the LICENSE.TXT in the root directory.
*****************************************************************************************************



*** Caught exception c0000005 (EXCEPTION_ACCESS_VIOLATION) [address=0000000000000008, ip=00007FFC02861326] ***

[00007FF67AAF3320]
[00007FF67AAF36D9]
[00007FFC02C00B1C] UnhandledExceptionFilter+0x1ec
[00007FFC053596BD] RtlCopyMemory+0x2bbd
[00007FFC0533F667] _C_specific_handler+0x97
[00007FFC0535504F] _chkstk+0x12f
[00007FFC052CE866] RtlFindCharInUnicodeString+0xa96
[00007FFC0535403E] KiUserExceptionDispatcher+0x2e
[00007FFC02861326] memmove+0x126
[00007FF67AC72098] vhpi_is_printable+0x922f8
[00007FF67AC709A5] vhpi_is_printable+0x90c05
[00007FF67AC709A5] vhpi_is_printable+0x90c05
[00007FF67ABC75D7] std_env_get_assert_format+0x2d87
[00007FF67ABC7E4A] std_env_get_assert_format+0x35fa
[00007FF67AB47D6B]
[00007FF67AB453E7]
[00007FF67AAE8E59]
[00007FF67AAE2A2B]
[00007FF67AAD1311]
[00007FF67AAD1366]
[00007FFC04DC257D] BaseThreadInitThunk+0x1d
[00007FFC0530AF28] RtlUserThreadStart+0x28

Please report this bug at https://github.com/nickg/nvc/issues
(lldb) run
(rocess 80160 launched: 'C:\msys64\clang64\bin\nvc.exe' (x86_64)
Process 80160 stopped
* thread #1, stop reason = Exception 0xc0000005 encountered at address 0x7ffc02861326: Access violation reading location 0x00000008
    frame #0: 0x00007ffc02861326 ucrtbase.dll`memcpy + 294
ucrtbase.dll`memcpy:
->  0x7ffc02861326 <+294>: movdqu (%rdx), %xmm1
    0x7ffc0286132a <+298>: movdqu -0x10(%rdx,%r8), %xmm2
    0x7ffc02861331 <+305>: movdqu %xmm1, (%rcx)
    0x7ffc02861335 <+309>: movdqu %xmm2, -0x10(%rcx,%r8)
(lldb) bt
* thread #1, stop reason = Exception 0xc0000005 encountered at address 0x7ffc02861326: Access violation reading location 0x00000008
  * frame #0: 0x00007ffc02861326 ucrtbase.dll`memcpy + 294
    frame #1: 0x00007ff67ac72098 nvc.exe`jit_interp [inlined] interp_move(state=0x0000007de4cfe900, ir=<unavailable>) at jit-interp.c:761:4
    frame #2: 0x00007ff67ac71fe6 nvc.exe`jit_interp [inlined] interp_loop(state=0x0000007de4cfe900) at jit-interp.c:1010:10
    frame #3: 0x00007ff67ac7057e nvc.exe`jit_interp(f=<unavailable>, caller=<unavailable>, args=<unavailable>, tlab=<unavailable>) at jit-interp.c:1104:4
    frame #4: 0x00007ff67ac709a5 nvc.exe`jit_interp [inlined] interp_call(state=0x0000007de4cfebc0, ir=0x0000025989e14238) at jit-interp.c:638:7
    frame #5: 0x00007ff67ac7096d nvc.exe`jit_interp [inlined] interp_loop(state=0x0000007de4cfebc0) at jit-interp.c:971:10
    frame #6: 0x00007ff67ac7057e nvc.exe`jit_interp(f=<unavailable>, caller=<unavailable>, args=<unavailable>, tlab=<unavailable>) at jit-interp.c:1104:4
    frame #7: 0x00007ff67ac709a5 nvc.exe`jit_interp [inlined] interp_call(state=0x0000007de4cff040, ir=0x000002598418d460) at jit-interp.c:638:7
    frame #8: 0x00007ff67ac7096d nvc.exe`jit_interp [inlined] interp_loop(state=0x0000007de4cff040) at jit-interp.c:971:10
    frame #9: 0x00007ff67ac7057e nvc.exe`jit_interp(f=<unavailable>, caller=<unavailable>, args=<unavailable>, tlab=<unavailable>) at jit-interp.c:1104:4
    frame #10: 0x00007ff67abc75d7 nvc.exe`jit_try_vcall(j=0x0000025983d48380, f=0x0000025984181ad0, result=0x0000007de4cff510, args=0x0000007de4cff190, tlab=0x0000007de4cff180) at jit-core.c:666:7
    frame #11: 0x00007ff67abc7e4a nvc.exe`jit_try_call(j=0x0000025983d48380, handle=<unavailable>, result=0x0000007de4cff510) at jit-core.c:728:11
    frame #12: 0x00007ff67ab47d6b nvc.exe`elab_lower [inlined] eval_instance(jit=0x0000025983d48380, name=0x0000025981eadac0, context=0x0000000000000000) at eval.c:424:9
    frame #13: 0x00007ff67ab47d40 nvc.exe`elab_lower(b=<unavailable>, shape=<unavailable>, ctx=0x0000007de4cff580) at elab.c:1424:19
    frame #14: 0x00007ff67ab453e7 nvc.exe`elab_architecture(bind=0x0000025985a20030, arch=<unavailable>, config=<unavailable>, ctx=0x0000007de4cff7b0) at elab.c:1539:7
    frame #15: 0x00007ff67aae8e59 nvc.exe`process_command [inlined] elab(top=<unavailable>, jit=<unavailable>, ur=0x0000025983fd3740, cover=0x0000000000000000) at elab.c:2306:10
    frame #16: 0x00007ff67aae868c nvc.exe`process_command [inlined] elaborate(argc=10, argv=0x0000025981e2a540, state=0x0000007de4cffa40) at nvc.c:464:17
    frame #17: 0x00007ff67aae868c nvc.exe`process_command(argc=10, argv=0x0000025981e2a540, state=0x0000007de4cffa40) at nvc.c:1922:14
    frame #18: 0x00007ff67aae2a2b nvc.exe`main(argc=<unavailable>, argv=<unavailable>) at nvc.c:2060:20
    frame #19: 0x00007ff67aad1311 nvc.exe`__tmainCRTStartup at crtexe.c:267:15
    frame #20: 0x00007ff67aad1366 nvc.exe`mainCRTStartup at crtexe.c:188:9
    frame #21: 0x00007ffc04dc257d kernel32.dll`BaseThreadInitThunk + 29
    frame #22: 0x00007ffc0530af28 ntdll.dll`RtlUserThreadStart + 40
Thread 1 received signal SIGSEGV, Segmentation fault.
0x00007ffc02861326 in ucrtbase!memmove () from C:\Windows\System32\ucrtbase.dll
(gdb) bt
#0  0x00007ffc02861326 in ucrtbase!memmove () from C:\Windows\System32\ucrtbase.dll
#1  0x00007ff67ac72098 in interp_move (state=0x14ece0, ir=<optimized out>) at ../src/jit/jit-interp.c:761
#2  interp_loop (state=0x14ece0) at ../src/jit/jit-interp.c:1010
#3  jit_interp (f=<optimized out>, caller=<optimized out>, args=<optimized out>, tlab=<optimized out>) at ../src/jit/jit-interp.c:1104
#4  0x00007ff67ac709a5 in interp_call (state=0x14efa0, ir=0x8676398) at ../src/jit/jit-interp.c:638
#5  interp_loop (state=0x14efa0) at ../src/jit/jit-interp.c:971
#6  jit_interp (f=<optimized out>, caller=<optimized out>, args=<optimized out>, tlab=<optimized out>) at ../src/jit/jit-interp.c:1104
#7  0x00007ff67ac709a5 in interp_call (state=0x14f420, ir=0x2b3d460) at ../src/jit/jit-interp.c:638
#8  interp_loop (state=0x14f420) at ../src/jit/jit-interp.c:971
#9  jit_interp (f=<optimized out>, caller=<optimized out>, args=<optimized out>, tlab=<optimized out>) at ../src/jit/jit-interp.c:1104
#10 0x00007ff67abc75d7 in jit_try_vcall (j=0x6639a0, f=0x2b31f10, result=0x14f8f0, args=0x14f570, tlab=0x14f560) at ../src/jit/jit-core.c:666
#11 0x00007ff67abc7e4a in jit_try_call (j=0x6639a0, handle=<optimized out>, result=0x14f8f0) at ../src/jit/jit-core.c:728
#12 0x00007ff67ab47d6b in eval_instance (jit=0x6639a0, name=0x65de30, context=0x0) at ../src/eval.c:424
#13 elab_lower (b=<optimized out>, shape=<optimized out>, ctx=0x14f960) at ../src/elab.c:1424
#14 0x00007ff67ab453e7 in elab_architecture (bind=0x43d0030, arch=<optimized out>, config=<optimized out>, ctx=0x14fb90) at ../src/elab.c:1539
#15 0x00007ff67aae8e59 in elab (top=<optimized out>, jit=<optimized out>, ur=0x296de80, cover=0x0) at ../src/elab.c:2306
#16 elaborate (argc=10, argv=0x5d4eb0, state=0x14fe20) at ../src/nvc.c:464
#17 process_command (argc=10, argv=0x5d4eb0, state=0x14fe20) at ../src/nvc.c:1922
#18 0x00007ff67aae2a2b in main (argc=2060180616, argv=0x8) at ../src/nvc.c:2060
(gdb)

This is the last function it processes before the exception, I just redacted some library names.
The enum I mentioned is not related to this package, so it might be a red herring. Though it is in the same VVC as the one I removed the "disable_log_message" for.

Name       ***redacted***.TRANSACTION_PKG.***redacted***_SB_PKG.T_GENERIC_SB
Kind       protected
Context    ***redacted***.TRANSACTION_PKG.***redacted***_SB_PKG
Blocks     5
Registers  83
Types      40
  BITVIS_VIP_SCOREBOARD.GENERIC_SB_SUPPORT_PKG.T_SB_CONFIG {0..9, 0..1, 0..1, 0..9, -2^63..2^63-1, 0..1}
Variables  13
  VR_SCOPE                              // [40] : 0..255 => 0..255
  VR_CONFIG                             // [101] : BITVIS_VIP_SCOREBOARD.GENERIC_SB_SUPPORT_PKG.T_SB_CONFIG{} => BITVIS_VIP_SCOREBOARD.GENERIC_SB_SUPPORT_PKG.T_SB_CONFIG{}
  i11                                   // #, temp
  VR_INSTANCE_ENABLED                   // [101] : 0..1 => 0..1
  VR_SB_QUEUE                           // P<***redacted***.TRANSACTION_PKG.***redacted***_SB_PKG.SB_QUEUE_PKG.T_GENERIC_QUEUE>
  VR_MSG_ID_PANEL_ARRAY                 // [8585] : 0..2 => 0..2
  VR_ENTERED_CNT                        // [101] : -2^31..2^31-1 => -2^31..2^31-1
  VR_MATCH_CNT                          // [101] : -2^31..2^31-1 => -2^31..2^31-1
  VR_MISMATCH_CNT                       // [101] : -2^31..2^31-1 => -2^31..2^31-1
  VR_DROP_CNT                           // [101] : -2^31..2^31-1 => -2^31..2^31-1
  VR_INITIAL_GARBAGE_CNT                // [101] : -2^31..2^31-1 => -2^31..2^31-1
  VR_DELETE_CNT                         // [101] : -2^31..2^31-1 => -2^31..2^31-1
  VR_OVERDUE_CHECK_CNT                  // [101] : -2^31..2^31-1 => -2^31..2^31-1
Begin
   0: r0 := const 40                    // # => 40
      r1 := index VR_SCOPE              // @<0..255> => 0..255
      r2 := const 63                    // 0..255 => 63
      r3 := const 95                    // 0..255 => 95
      r4 := const 83                    // 0..255 => 83
      r5 := const 66                    // 0..255 => 66
      r6 := const 0                     // 0..255 => 0
      r7 := const [r2,r3,r4,r5,r6,r6,r6,r6,r6,r6,r6,r6,r6,r6,r6,r6,r6,r6,r6,r6,r6,r6,r6,r6,r6,r6,r6,r6,r6,r6,r6,r6,r6,r6,r6,r6,r6,r6,r6,r6] // [40] : 0..255 => 0..255
      r8 := address of r7               // @<0..255> => 0..255
      r1 := copy r8 count r0
      r15 := const 101                  // # => 101
      r16 := index VR_CONFIG            // @<BITVIS_VIP_SCOREBOARD.GENERIC_SB_SUPPORT_PKG.T_SB_CONFIG{}> => BITVIS_VIP_SCOREBOARD.GENERIC_SB_SUPPORT_PKG.T_SB_CONFIG{}
      r20 := const 1                    // # => 1
      r21 := const 0                    // # => 0
      i11 := store r21
      jump 1
   1: r22 := load i11                   // #
      r23 := add r22 + r20              // # => -9223372036854775807..2^63-1
      i11 := store r23
      r24 := array ref r16 offset r22   // @<BITVIS_VIP_SCOREBOARD.GENERIC_SB_SUPPORT_PKG.T_SB_CONFIG{}> => BITVIS_VIP_SCOREBOARD.GENERIC_SB_SUPPORT_PKG.T_SB_CONFIG{}
      r25 := var upref 1, SB_CONFIG_DEFAULT // @<BITVIS_VIP_SCOREBOARD.GENERIC_SB_SUPPORT_PKG.T_SB_CONFIG{}>
      r24 := copy r25
      r26 := cmp r23 == r15
      cond r26 then 2 else 1
   2: r30 := const 0                    // 0..1 => 0
      r34 := const 101                  // # => 101
      r35 := index VR_INSTANCE_ENABLED  // @<0..1> => 0..1
      r35 := memset r30 length r34
      r38 := link package ***redacted***.TRANSACTION_PKG.***redacted***_SB_PKG.SB_QUEUE_PKG // P<***redacted***.TRANSACTION_PKG.***redacted***_SB_PKG.SB_QUEUE_PKG>
      r39 := protected init ***redacted***.TRANSACTION_PKG.***redacted***_SB_PKG.SB_QUEUE_PKG.T_GENERIC_QUEUE context r38 // P<***redacted***.TRANSACTION_PKG.***redacted***_SB_PKG.SB_QUEUE_PKG.T_GENERIC_QUEUE>
      VR_SB_QUEUE := store r39
      r41 := const 85                   // # => 85
      r42 := const 8585                 // # => 8585
      r43 := index VR_MSG_ID_PANEL_ARRAY // @<0..2> => 0..2
      r44 := link package UVVM_UTIL.ADAPTATIONS_PKG // P<UVVM_UTIL.ADAPTATIONS_PKG>
      r45 := link var r44 C_SB_MSG_ID_PANEL_DEFAULT // @<0..2> => 0..2
      r46 := const 0                    // # => 0
      i11 := store r46
      jump 3
   3: r47 := load i11                   // #
      r48 := add r47 + r41              // # => -9223372036854775723..2^63-1
      i11 := store r48
      r49 := array ref r43 offset r47   // @<0..2> => 0..2
      r50 := link package UVVM_UTIL.ADAPTATIONS_PKG // P<UVVM_UTIL.ADAPTATIONS_PKG>
      r51 := link var r50 C_SB_MSG_ID_PANEL_DEFAULT // @<0..2> => 0..2
      r49 := copy r51 count r41
      r52 := cmp r48 == r42
      cond r52 then 4 else 3
   4: r60 := const 101                  // # => 101
      r61 := index VR_ENTERED_CNT       // @<-2^31..2^31-1> => -2^31..2^31-1
      r62 := const -1                   // -2^31..2^31-1 => -1
      r61 := memset r62 length r60
      r65 := index VR_MATCH_CNT         // @<-2^31..2^31-1> => -2^31..2^31-1
      r65 := memset r62 length r60
      r68 := index VR_MISMATCH_CNT      // @<-2^31..2^31-1> => -2^31..2^31-1
      r68 := memset r62 length r60
      r71 := index VR_DROP_CNT          // @<-2^31..2^31-1> => -2^31..2^31-1
      r71 := memset r62 length r60
      r74 := index VR_INITIAL_GARBAGE_CNT // @<-2^31..2^31-1> => -2^31..2^31-1
      r74 := memset r62 length r60
      r77 := index VR_DELETE_CNT        // @<-2^31..2^31-1> => -2^31..2^31-1
      r77 := memset r62 length r60
      r80 := index VR_OVERDUE_CHECK_CNT // @<-2^31..2^31-1> => -2^31..2^31-1
      r80 := memset r62 length r60
      return
@nickg
Copy link
Owner

nickg commented Aug 12, 2024

Maybe try configuring with --enable-debug and see if you hit any assertion failures.

@nickg nickg added the crash label Aug 12, 2024
@avelure
Copy link
Author

avelure commented Aug 13, 2024

I forgot to save the problematic test, but this one seems to be the same. It is in the same T_GENERIC_SB function but the stack is slightly different.

------------------------------------------------------------
**redacted**.TRANSACTION_PKG.**redacted**SB_PKG.T_GENERIC_SB:
        $GALLOC       R1, #0x36b8
        RECV          R0, #0
        STORE.64      R0, [R1]
        DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:543>, 0:13
        MOV           R2, #40
        $COPY         R2, [R1+8], [CP+0]
        DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:544>, 0:20
        STORE.64      #0, [R1+2472]
        DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:544>, 0:21
L1:     DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:544>, 1:0
        LOAD.64       R3, [R1+2472]
        DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:544>, 1:1
        ADD           R4, R3, #1
        DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:544>, 1:2
        STORE.64      R4, [R1+2472]
        DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:544>, 1:3
        MUL           R6, R3, #24
        LEA           R5, [R1+48]
        ADD           R7, R5, R6
        DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:544>, 1:4
        LOAD.64       R8, [R1]
        DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:544>, 1:5
        MOV           R9, #24
        $MOVE         R9, [R7], [R8+8]
        DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:544>, 1:6
        CMP.EQ        R4, #101
        DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:544>, 1:7
        JUMP.F        L1
        DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:545>, 2:7
        MOV           R10, #101
        $BZERO        R10, [R1+2480]
        DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:546>, 2:12
        $GETPRIV      R11, <**redacted**.TRANSACTION_PKG.**redacted**SB_PKG.SB_QUEUE_PKG>
        DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:546>, 2:13
        SEND          #0, R11
        CALL          <**redacted**.TRANSACTION_PKG.**redacted**SB_PKG.SB_QUEUE_PKG.T_GENERIC_QUEUE>
        RECV          R12, #0
        DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:546>, 2:14
        STORE.64      R12, [R1+2584]
        DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:549>, 2:20
        DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:549>, 2:25
        STORE.64      #0, [R1+2472]
        DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:549>, 2:26
L2:     DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:549>, 3:0
        LOAD.64       R13, [R1+2472]
        DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:549>, 3:1
        ADD           R14, R13, #85
        DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:549>, 3:2
        STORE.64      R14, [R1+2472]
        DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:549>, 3:3
        LEA           R15, [R1+2592]
        ADD           R16, R15, R13
        DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:549>, 3:4
        $GETPRIV      R17, <UVVM_UTIL.ADAPTATIONS_PKG>
        DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:549>, 3:6
        MOV           R18, #85
        $MOVE         R18, [R16], [R17+1072]
        DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:549>, 3:7
        CMP.EQ        R14, #0x2189
        DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:549>, 3:8
        JUMP.F        L2
        DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:552>, 4:7
        MOV           R19, #404
        $MEMSET.32    R19, [R1+11180], #-1
        DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:553>, 4:13
        MOV           R20, #404
        $MEMSET.32    R20, [R1+11584], #-1
        DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:554>, 4:19
        MOV           R21, #404
        $MEMSET.32    R21, [R1+11988], #-1
        DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:555>, 4:25
        MOV           R22, #404
        $MEMSET.32    R22, [R1+12392], #-1
        DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:556>, 4:31
        MOV           R23, #404
        $MEMSET.32    R23, [R1+12796], #-1
        DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:557>, 4:37
        MOV           R24, #404
        $MEMSET.32    R24, [R1+13200], #-1
        DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:558>, 4:43
        MOV           R25, #404
        $MEMSET.32    R25, [R1+13604], #-1
        DEBUG         <C:\proj\**redacted**\tools\uvvm\bitvis_vip_scoreboard\src\generic_sb_pkg.vhd:538>, 4:48
        SEND          #0, R1
        RET
------------------------------------------------------------

Arguments:
        A0      0

Registers:
        R0      0
        R1      13e7c191ac0 ==> 14016 byte mspace object
                        >00 00 00 00  00 00 00 00 |........|
                         3f 5f 53 42  00 00 00 00 |?_SB....|
                         00 00 00 00  00 00 00 00 |........|
                                ... skipped 2448 identical bytes ...
                         01 00 00 00  00 00 00 00 |........|
                         00 00 00 00  00 00 00 00 |........|
                                ... skipped 11520 identical bytes ...
                         00 00 00 00  00 00 00 00 |........|
        R2      28 (40)
        R3      0
        R4      1
        R5      13e7c191af0 ==> 14016 byte mspace object
                         00 00 00 00  00 00 00 00 |........|
                         3f 5f 53 42  00 00 00 00 |?_SB....|
                         00 00 00 00  00 00 00 00 |........|
                                ... skipped 2448 identical bytes ...
                         01 00 00 00  00 00 00 00 |........|
                         00 00 00 00  00 00 00 00 |........|
                                ... skipped 11520 identical bytes ...
                         00 00 00 00  00 00 00 00 |........|
        R6      0
        R7      13e7c191af0 ==> 14016 byte mspace object
                         00 00 00 00  00 00 00 00 |........|
                         3f 5f 53 42  00 00 00 00 |?_SB....|
                         00 00 00 00  00 00 00 00 |........|
                                ... skipped 2448 identical bytes ...
                         01 00 00 00  00 00 00 00 |........|
                         00 00 00 00  00 00 00 00 |........|
                                ... skipped 11520 identical bytes ...
                         00 00 00 00  00 00 00 00 |........|
        R8      0
        R9      18 (24)
        R10     dededededededede
        R11     dededededededede
        R12     dededededededede
        R13     dededededededede
        R14     dededededededede
        R15     dededededededede
        R16     dededededededede
        R17     dededededededede
        R18     dededededededede
        R19     dededededededede
        R20     dededededededede
        R21     dededededededede
        R22     dededededededede
        R23     dededededededede
        R24     dededededededede
        R25     dededededededede

Flags: F

Constant pool:
        3f 5f 53 42  00 00 00 00  00 00 00 00  00 00 00 00  |?_SB............|
        00 00 00 00  00 00 00 00  00 00 00 00  00 00 00 00  |................|
        00 00 00 00  00 00 00 00                            |........        |

fatal: assertion '(uintptr_t)src >= 4096 || count == 0' failed
[00007FF6FB3F87C0]
[00007FF6FB45FA06]
[00007FF6FB3F7708]
[00007FF6FB51CAAC] vhpi_is_printable+0x83d5c
[00007FF6FB51A1C3] vhpi_is_printable+0x81473
[00007FF6FB51A822] vhpi_is_printable+0x81ad2
[00007FF6FB51A1C3] vhpi_is_printable+0x81473
[00007FF6FB51A822] vhpi_is_printable+0x81ad2
[00007FF6FB51A1C3] vhpi_is_printable+0x81473
[00007FF6FB4837EC] std_env_get_assert_format+0x1e5c
[00007FF6FB483558] std_env_get_assert_format+0x1bc8
[00007FF6FB4DC341] vhpi_is_printable+0x435f1
[00007FF6FB42B323]
[00007FF6FB4295F2]
[00007FF6FB428EFB]
[00007FF6FB3F3F9B]
[00007FF6FB3F17B0]
[00007FF6FB3F1313]
[00007FF6FB3F1366]
[00007FFC04DC257D] BaseThreadInitThunk+0x1d
[00007FFC0530AF28] RtlUserThreadStart+0x28

If I break on exit GDB gives

#0  0x00007ffc0282be20 in ucrtbase!exit () from C:\Windows\System32\ucrtbase.dll
#1  0x00007ff6fb3f8565 in fatal_exit (status=status@entry=1) at ../src/util.c:504
#2  0x00007ff6fb3f7712 in fatal_trace (fmt=0x7ff6fb5902cc <__make_binary.tbl_BINARY+1662> "assertion '%s' failed") at ../src/util.c:586
#3  0x00007ff6fb51caac in interp_loop (state=state@entry=0x14ed28) at ../src/jit/jit-interp.c:1059
#4  0x00007ff6fb51a1c3 in jit_interp (f=0x92f7620, caller=<optimized out>, args=0x14f6b0, tlab=0x14f6a0) at ../src/jit/jit-interp.c:1104
#5  0x00007ff6fb51a822 in interp_call (state=0x14f058, ir=0x9406910) at ../src/jit/jit-interp.c:638
#6  interp_loop (state=state@entry=0x14f058) at ../src/jit/jit-interp.c:971
#7  0x00007ff6fb51a1c3 in jit_interp (f=0x2b1a520, caller=<optimized out>, args=0x14f6b0, tlab=0x14f6a0) at ../src/jit/jit-interp.c:1104
#8  0x00007ff6fb51a822 in interp_call (state=0x14f548, ir=0x2b3d610) at ../src/jit/jit-interp.c:638
#9  interp_loop (state=state@entry=0x14f548) at ../src/jit/jit-interp.c:971
#10 0x00007ff6fb51a1c3 in jit_interp (f=0x2b18130, caller=<optimized out>, args=0x14f6b0, tlab=0x14f6a0) at ../src/jit/jit-interp.c:1104
#11 0x00007ff6fb4837ec in jit_try_vcall (j=j@entry=0x296c8a0, f=f@entry=0x2b18130, result=result@entry=0x14fa28, args=args@entry=0x14f6b0, tlab=0x14f6a0) at ../src/jit/jit-core.c:666
#12 0x00007ff6fb483558 in jit_try_call (j=j@entry=0x296c8a0, handle=<optimized out>, result=result@entry=0x14fa28) at ../src/jit/jit-core.c:728
#13 0x00007ff6fb4dc341 in eval_instance (jit=0x296c8a0, name=0x48e610, context=0x0) at ../src/eval.c:424
#14 0x00007ff6fb42b323 in elab_lower (b=b@entry=0x4ff33d0, shape=shape@entry=0x0, ctx=ctx@entry=0x14fac8) at ../src/elab.c:1424
#15 0x00007ff6fb4295f2 in elab_architecture (bind=bind@entry=0x4ff0030, arch=arch@entry=0x950000, config=config@entry=0x0, ctx=ctx@entry=0x14fc10) at ../src/elab.c:1539
#16 0x00007ff6fb428efb in elab (top=top@entry=0x950000, jit=<optimized out>, ur=0x4ea5c0, cover=cover@entry=0x0) at ../src/elab.c:2306
#17 0x00007ff6fb3f3f9b in elaborate (argc=10, argv=0x404eb0, state=0x14fe20) at ../src/nvc.c:464
#18 process_command (argc=10, argv=0x404eb0, state=state@entry=0x14fe20) at ../src/nvc.c:1922
#19 0x00007ff6fb3f17b0 in main (argc=1, argv=0x400000) at ../src/nvc.c:2060

@nickg
Copy link
Owner

nickg commented Aug 15, 2024

The constructor for the protected type should receive a pointer to its enclosing environment (the instance of the generic_sb_pkg package) but that is null here for some reason. What does the package instantiation look like? Is it similar to the following from bitvis_vip_spi?

  package spi_sb_pkg is new bitvis_vip_scoreboard.generic_sb_pkg
    generic map(t_element         => std_logic_vector(C_VVC_CMD_DATA_MAX_LENGTH - 1 downto 0),
                element_match     => std_match,
                to_string_element => to_string);
  use spi_sb_pkg.all;
  shared variable SPI_VVC_SB : spi_sb_pkg.t_generic_sb;

@avelure
Copy link
Author

avelure commented Aug 16, 2024

No, that implementation gives a GHDL error (ghdl/ghdl#2510) as both the package declaration and instantiation is in the same package.
This has been updated in one of the later UVVM tags where there is a new vvc_sb_pkg.
In my custom VVC I made a quick fix which was to move the declaration to the bottom of transaction_pkg.
So transaction_pkg

  package ***redacted***_sb_pkg is new bitvis_vip_scoreboard.generic_sb_pkg
       generic map (t_element         => std_logic_vector(C_VVC_CMD_DATA_MAX_LENGTH-1 downto 0),
                    element_match     => std_match,
                    to_string_element => to_string);

vvc_methods_pkg

shared variable ***redacted***_VVC_SB  : ***redacted***_sb_pkg.t_generic_sb;

@nickg
Copy link
Owner

nickg commented Aug 17, 2024

Here's a reproducer:

package genpack is
    generic (type t);

    type pt is protected
        impure function get return t;
        impure function get_str return string;
        procedure put (val : t);
    end protected;
end package;

package body genpack is
    constant str : string := "hello world";

    type pt is protected body
        variable cur : t;

        impure function get return t is
        begin
            return cur;
        end function;

        procedure put (val : t) is
        begin
            cur := val;
        end procedure;

        impure function get_str return string is
        begin
            return str;                 -- Accesses parent package
        end function;
    end protected body;
end package body;

-------------------------------------------------------------------------------

package testpack is
    package int_pack is new work.genpack
        generic map ( t => integer );
    use int_pack.all;
end package;

-------------------------------------------------------------------------------

entity issue943 is
end entity;

use work.testpack.all;

architecture test of issue943 is
    shared variable sv : int_pack.pt;
begin

    check: process is
    begin
        sv.put(5);
        assert sv.get = 5;
        assert sv.get_str = "hello world";

        wait;
    end process;

end architecture;

@nickg
Copy link
Owner

nickg commented Aug 17, 2024

Can you test again with the latest master branch?

@avelure
Copy link
Author

avelure commented Aug 19, 2024

Yes, it works!
Thanks for investigating.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants