Skip to content

Member access within misaligned address after threaded allocator patch #20877

Open
@planetis-m

Description

@planetis-m

What happened?

const
  cacheLineSize = 64

type
  SpscQueue = object
    cachedHead {.align(cacheLineSize).}: int

proc main =
  let a = cast[ptr SpscQueue](allocShared(sizeof(SpscQueue)))
  assert a[].cachedHead == 0
  deallocShared(a)

main()

compile on devel (implies --threads:on --mm:orc) with:

nim c -t:"-fsanitize=address,undefined" -l:"-fsanitize=address,undefined" -d:nosignalhandler -d:release -g tbug

Nim Version

Nim Compiler Version 1.7.3 [Linux: amd64]
Compiled at 2022-11-17
Copyright (c) 2006-2022 by Andreas Rumpf

git hash: 1707bc4
active boot switches: -d:release --gc:markAndSweep

Current Standard Output Logs

tbug.nim:13:16: runtime error: store to misaligned address 0x7f6b3c860050 for type 'struct tyObject_SpscQueue__aotEC3Ym48dzfCy9crhmi6A', which requires 64 byte alignment
0x7f6b3c860050: note: pointer points here
 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
              ^ 
tbug.nim:27:147: runtime error: member access within misaligned address 0x7f6b3c860050 for type 'struct tyObject_SpscQueue__aotEC3Ym48dzfCy9crhmi6A', which requires 64 byte alignment
0x7f6b3c860050: note: pointer points here
 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00
              ^

Expected Standard Output Logs

No response

Possible Solution

No response

Additional Information

This is a regression from #20492

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions