[USRP-users] Re: Bus errors and UHD exceptions with simple I/Q recorder

2022-08-14 Thread woznych
Nikos,

Thanks for the reply. I traced it to the “recv” call which has left me puzzled. 
I added a bunch of instrumentation to see if I was walking off the end of my 
memory that was allocated to the 16-bit I/Q buffer.

`const std::int32_t startIndex = 2*num_accum_samps;`

`const std::int32_t remainingSize = 2*sampleLength-(2*num_accum_samps);`

`std::cout << "iq[" << startIndex << "] = " << iq[startIndex];`

`std::cout << "\t" << remainingSize;`

`std::cout << "\t" << startIndex + remainingSize;`

`std::cout << "\t" << bufferSize << std::endl;`

`num_accum_samps += rx_stream->recv(&iq[startIndex], remainingSize, meta, 5.0, 
true);`

And I can get it to faithfully crash every single time when I don’t pad my 
array of 16-bit integers by an additional 2165 int16s. I included some output 
indicating where I’ve specified as the start of the buffer for it to write to, 
followed by the remaining size, followed by the sum of the two just to make 
sure I can math, and finally the actual reserved buffer size plus the pad of 
2164 int16s.

`…`

`iq[1180480] = 019520   120 1202164`

`iq[1185920] = 014080   120 1202164`

`iq[1191360] = 08640120 1202164`

`iq[1196800] = 03200120 1202164`

`Segmentation fault (core dumped)`

If you’ll notice, I’ve specified for it to start at index 1196800 and that the 
number of samples per buffer being passed to recv() is 3200. I think I’m just 
being dense / misinterpreting the *nsamps_per_buff* (the second parameter of 
the “recv” call) because it seems as if it is not respecting the remaining 
buffer size that I am specifying and attempting to write beyond the bounds of 
the memory I’ve allocated for the buffer.

Is there some alignment or minimum buffer size that I’m not aware of?

Thanks,

Chris
___
USRP-users mailing list -- usrp-users@lists.ettus.com
To unsubscribe send an email to usrp-users-le...@lists.ettus.com


[USRP-users] Re: Bus errors and UHD exceptions with simple I/Q recorder

2022-08-14 Thread Nikos Balkanas
Aaaah, it's the dreaded max_samps_per_buffer:(
Yup, you need to make your read buffer aligned to max_samps_per_buffer...

HTH
Nikos

On Sun, Aug 14, 2022 at 9:24 PM  wrote:
>
> Nikos,
>
> Thanks for the reply. I traced it to the “recv” call which has left me 
> puzzled. I added a bunch of instrumentation to see if I was walking off the 
> end of my memory that was allocated to the 16-bit I/Q buffer.
>
> const std::int32_t startIndex = 2*num_accum_samps;
>
> const std::int32_t remainingSize = 2*sampleLength-(2*num_accum_samps);
>
> std::cout << "iq[" << startIndex << "] = " << iq[startIndex];
>
> std::cout << "\t" << remainingSize;
>
> std::cout << "\t" << startIndex + remainingSize;
>
> std::cout << "\t" << bufferSize << std::endl;
>
> num_accum_samps += rx_stream->recv(&iq[startIndex], remainingSize, meta, 5.0, 
> true);
>
> And I can get it to faithfully crash every single time when I don’t pad my 
> array of 16-bit integers by an additional 2165 int16s. I included some output 
> indicating where I’ve specified as the start of the buffer for it to write 
> to, followed by the remaining size, followed by the sum of the two just to 
> make sure I can math, and finally the actual reserved buffer size plus the 
> pad of 2164 int16s.
>
> …
>
> iq[1180480] = 0 19520 120 1202164
>
> iq[1185920] = 0 14080 120 1202164
>
> iq[1191360] = 0 8640 120 1202164
>
> iq[1196800] = 0 3200 120 1202164
>
> Segmentation fault (core dumped)
>
> If you’ll notice, I’ve specified for it to start at index 1196800 and that 
> the number of samples per buffer being passed to recv() is 3200. I think I’m 
> just being dense / misinterpreting the nsamps_per_buff (the second parameter 
> of the “recv” call) because it seems as if it is not respecting the remaining 
> buffer size that I am specifying and attempting to write beyond the bounds of 
> the memory I’ve allocated for the buffer.
>
> Is there some alignment or minimum buffer size that I’m not aware of?
>
> Thanks,
>
> Chris
>
> ___
> USRP-users mailing list -- usrp-users@lists.ettus.com
> To unsubscribe send an email to usrp-users-le...@lists.ettus.com
___
USRP-users mailing list -- usrp-users@lists.ettus.com
To unsubscribe send an email to usrp-users-le...@lists.ettus.com


[USRP-users] Re: Bus errors and UHD exceptions with simple I/Q recorder

2022-08-14 Thread Marcus D. Leech

On 2022-08-14 20:57, Nikos Balkanas wrote:

Aaaah, it's the dreaded max_samps_per_buffer:(
Yup, you need to make your read buffer aligned to max_samps_per_buffer...

HTH
Nikos

I'll note that rx_samples_to_file uses:

    std::vector buff(samps_per_buff);

For its buffer.  I don't know whether std::vector arranges for alignment.




On Sun, Aug 14, 2022 at 9:24 PM  wrote:

Nikos,

Thanks for the reply. I traced it to the “recv” call which has left me puzzled. 
I added a bunch of instrumentation to see if I was walking off the end of my 
memory that was allocated to the 16-bit I/Q buffer.

const std::int32_t startIndex = 2*num_accum_samps;

const std::int32_t remainingSize = 2*sampleLength-(2*num_accum_samps);

std::cout << "iq[" << startIndex << "] = " << iq[startIndex];

std::cout << "\t" << remainingSize;

std::cout << "\t" << startIndex + remainingSize;

std::cout << "\t" << bufferSize << std::endl;

num_accum_samps += rx_stream->recv(&iq[startIndex], remainingSize, meta, 5.0, 
true);

And I can get it to faithfully crash every single time when I don’t pad my 
array of 16-bit integers by an additional 2165 int16s. I included some output 
indicating where I’ve specified as the start of the buffer for it to write to, 
followed by the remaining size, followed by the sum of the two just to make 
sure I can math, and finally the actual reserved buffer size plus the pad of 
2164 int16s.

…

iq[1180480] = 0 19520 120 1202164

iq[1185920] = 0 14080 120 1202164

iq[1191360] = 0 8640 120 1202164

iq[1196800] = 0 3200 120 1202164

Segmentation fault (core dumped)

If you’ll notice, I’ve specified for it to start at index 1196800 and that the 
number of samples per buffer being passed to recv() is 3200. I think I’m just 
being dense / misinterpreting the nsamps_per_buff (the second parameter of the 
“recv” call) because it seems as if it is not respecting the remaining buffer 
size that I am specifying and attempting to write beyond the bounds of the 
memory I’ve allocated for the buffer.

Is there some alignment or minimum buffer size that I’m not aware of?

Thanks,

Chris

___
USRP-users mailing list -- usrp-users@lists.ettus.com
To unsubscribe send an email to usrp-users-le...@lists.ettus.com

___
USRP-users mailing list -- usrp-users@lists.ettus.com
To unsubscribe send an email to usrp-users-le...@lists.ettus.com

___
USRP-users mailing list -- usrp-users@lists.ettus.com
To unsubscribe send an email to usrp-users-le...@lists.ettus.com