Hi,

Thanks for the help. It turns out that the problem was that the L1Dir constructor was not being called. I resolved this by calling the constructor with the `construct_at`function.

Best,
Rumen

From: Alexander Boettcher <alexander.boettcher@genode-labs.com>
Sent: Friday, January 24, 2025 9:38 AM
To: users@lists.genode.org <users@lists.genode.org>
Subject: Re: Trying to modify Bit_array throws 'Invalid_index_access'
 
CAUTION: This email originated from outside the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.


Hi,

I took your L1 calculation and tried:

#define BITS_PER_WORD sizeof(addr_t) * 8UL
#define WORD_ALIGN(_BITS) (BITS_PER_WORD) - (_BITS % (BITS_PER_WORD)) + _BITS
static const unsigned int L1_SIZE . = WORD_ALIGN(256);

log(" ", L1_SIZE); -> 320

Bit_array<L1_SIZE> test { };
test.set(0, L1_SIZE);


which works without exception.


The exception is only thrown at one specific place in the bit_array implementation. Just instrument it and see which of the 3 condition don't match for you.

Cheers,

Alex.


On 22.01.25 16:20, Rumen Mitov wrote:
> Hello,
>
> I am facing a problem when using the Bit_array class.
>
> I have a class called L1Dir which contains the property freemask which is a Bit_array with L1_SIZE bits. I want to initialize every bit to value 1 in freemask. However, when I try to call freemask.set(0, L1Dir) outside of the L1Dir default constructor the following error is thrown: 'Genode::Bit_array_base::Invalid_index_access'.
>
> I have tried changing the call to freemask.set(1,2) but I still get the same exception. I have also tried with freemask.get(...) and freemask.clear(...) with no success.
>
> I have initialized freemask with enough space:
>
> Genode::Bit_array<L1_SIZE> freemask;
>
> This leads me to believe that the problem has something to do with the underlying memory of Bit_array_base. If you know what I am doing wrong, please let me know!
>
> Best,
> Rumen
>
>
> P.S. If you need more context, you can find the current state of my code here: https://github.com/rumenmitov/genode-squid/tree/a726c5da3099a7f5de1d4d3d98a59b3a77812000
>
>
>
>
>
>
>
>
> _______________________________________________
> users mailing list -- users@lists.genode.org
> To unsubscribe send an email to users-leave@lists.genode.org
> Archived at https://lists.genode.org/mailman3/hyperkitty/list/users@lists.genode.org/message/BPSXQKAFPSEIL2LBOGZMAAAXU4VNBAT4/

--
Alexander Boettcher
Genode Labs

https://www.genodians.org - https://www.genode.org

_______________________________________________
users mailing list -- users@lists.genode.org
To unsubscribe send an email to users-leave@lists.genode.org
Archived at https://lists.genode.org/mailman3/hyperkitty/list/users@lists.genode.org/message/Y7UV5RC7RQVSQTI4EFGD2O6PDTVZXCXU/