Skip to content

Only allow explicit template instantiations in one object file - #2

Merged
tstenner merged 1 commit into
masterfrom
multiple_definition
Aug 24, 2018
Merged

tstenner merged 1 commit into
masterfrom
multiple_definition

Conversation

@tstenner

@tstenner tstenner commented Aug 17, 2018

Copy link
Copy Markdown
Collaborator

This should fix fixes the multiple definition of typeinfo name for boost::archive::...` errors on ARM

@tstenner
tstenner requested a review from cboulay August 17, 2018 11:33
@tstenner tstenner changed the title Only allow explicit template instantiations in on object file Only allow explicit template instantiations in one object file Aug 17, 2018
@cboulay

cboulay commented Aug 17, 2018

Copy link
Copy Markdown
Collaborator

When merged with master I was able to use the cross-compile instructions from Ubuntu to build this hopefully Raspberry Pi compatible shared object. (Edit: Removed, see below)

I also tested the native build in Ubuntu 18.04 using the Benchmark tools and it seemed to work there. I'll update this post after I've tested in Mac and Windows. (As far as I know we don't have a unit test suite but let me know if I'm wrong).
Edit: Also tested Examples and Benchmarks on Mac and Windows and they appear to be working.

@tstenner

Copy link
Copy Markdown
Collaborator Author

I could reproduce the build failure with the master branch on my 3B (gcc 6.3), whereas this branch builds without any warnings.

@cboulay

cboulay commented Aug 19, 2018

Copy link
Copy Markdown
Collaborator

@tstenner
tstenner merged commit ac1571d into master Aug 24, 2018
@tstenner
tstenner deleted the multiple_definition branch August 24, 2018 12:03
cboulay added a commit that referenced this pull request Jun 17, 2026
Addresses review findings on the synchronous (zero-copy) outlet:

#1 Memory safety: the byte-swap path grew its scratch buffer with resize()
   inside the loop while holding pointers into it, so a reallocation dangled
   earlier const_buffers and sent freed memory to byte-swapped clients. The
   new sync_swap_buffers() reserves the exact size up front.

#2 Correctness: buffers were classified by size, so an 8-byte sample (e.g.
   2x int32 or 4x int16) was mistaken for a timestamp and reversed as one
   double instead of per channel value. Swapping is now driven by the sample
   tag, not buffer size, so it is correct for any sample_bytes.

#3 Portability: the per-sample tag was stored in a uint64_t and sent via its
   first byte, which is 0x00 on a big-endian host. It is now a uint8_t
   (sync_ts_entry), so the correct tag byte goes on the wire everywhere.

#4 Lifetime: sync mode now flushes on every push and ignores pushthrough.
   The gather buffers alias the caller's memory, so deferring the write
   (pushthrough == false) would retain dangling pointers once the caller
   reuses the buffer.

#5/#7 Docs: document sync mode as single-producer (the push path is
   unsynchronized) and note that disconnected consumers are detected lazily.

Also removes the unused scratch_ member and extracts the swap into an inline,
unit-testable helper (src/sync_serialization.h). New internal tests drive that
helper across the 8-byte-collision and many-sample (reallocation) cases that
no little-endian integration test can reach.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
cboulay added a commit that referenced this pull request Jun 17, 2026
Addresses review findings on the synchronous (zero-copy) outlet:

#1 Memory safety: the byte-swap path grew its scratch buffer with resize()
   inside the loop while holding pointers into it, so a reallocation dangled
   earlier const_buffers and sent freed memory to byte-swapped clients. The
   new sync_swap_buffers() reserves the exact size up front.

#2 Correctness: buffers were classified by size, so an 8-byte sample (e.g.
   2x int32 or 4x int16) was mistaken for a timestamp and reversed as one
   double instead of per channel value. Swapping is now driven by the sample
   tag, not buffer size, so it is correct for any sample_bytes.

#3 Portability: the per-sample tag was stored in a uint64_t and sent via its
   first byte, which is 0x00 on a big-endian host. It is now a uint8_t
   (sync_ts_entry), so the correct tag byte goes on the wire everywhere.

#4 Lifetime: sync mode now flushes on every push and ignores pushthrough.
   The gather buffers alias the caller's memory, so deferring the write
   (pushthrough == false) would retain dangling pointers once the caller
   reuses the buffer.

#5/#7 Docs: document sync mode as single-producer (the push path is
   unsynchronized) and note that disconnected consumers are detected lazily.

Also removes the unused scratch_ member and extracts the swap into an inline,
unit-testable helper (src/sync_serialization.h). New internal tests drive that
helper across the 8-byte-collision and many-sample (reallocation) cases that
no little-endian integration test can reach.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants