Hello Genodians,
I am attempting to familiarize myself with some of the provided data structures. When playing around with the Registry class, I encountered an interesting error. [1] is a GitHub gist containing the code I am running. I am wanting to use the Registry class to keep track of services announced by children on a parent component. When looking though the Genode repository, this seemed to be the accepted way to do this (please correct me if I am misunderstanding). When I run this code, I get the following output:
Genode 23.11 87 MiB RAM and 63252 caps assigned to init [init -> parent] Child requested session: 'PD' Error: illegal READ at address 0x4 by pager_object: pd='init -> parent' thread='ep' ip=0x7acf4
I would like to pass a reference to the Registry to each instance of Child_policy so I can use services announced by other children. As an additional experiment however, I tried creating a new Registry as a class member for each Child_policy (see the comment at the top of the Tutorial::Child class). This resulted in the following output:
Genode 23.11 87 MiB RAM and 63252 caps assigned to init [init -> parent] Child requested session: 'PD'
To me, this indicates that the for_each call is blocking. I cannot see, however, what would be holding the mutex before I get to this point. Any pointers in the right direction would be greatly appreciated :)
[1] https://gist.github.com/zgzollers/48181fbc2dac6e51015602c6329593f9
Thanks, Zachary Zollers
Hello Zachary,
On 15.02.24 15:49, Zachary Zollers wrote:
Hello Genodians,
I am attempting to familiarize myself with some of the provided data structures. When playing around with the Registry class, I encountered an interesting error. [1] is a GitHub gist containing the code I am running. I am wanting to use the Registry class to keep track of services announced by children on a parent component. When looking though the Genode repository, this seemed to be the accepted way to do this (please correct me if I am misunderstanding). When I run this code, I get the following output:
Genode 23.11 87 MiB RAM and 63252 caps assigned to init [init -> parent] Child requested session: 'PD' Error: illegal READ at address 0x4 by pager_object: pd='init -> parent' thread='ep' ip=0x7acf4
I would like to pass a reference to the Registry to each instance of Child_policy so I can use services announced by other children. As an additional experiment however, I tried creating a new Registry as a class member for each Child_policy (see the comment at the top of the Tutorial::Child class). This resulted in the following output:
Genode 23.11 87 MiB RAM and 63252 caps assigned to init [init -> parent] Child requested session: 'PD'
To me, this indicates that the for_each call is blocking. I cannot see, however, what would be holding the mutex before I get to this point. Any pointers in the right direction would be greatly appreciated :)
[1] https://gist.github.com/zgzollers/48181fbc2dac6e51015602c6329593f9
without looking much into your code, does it help to add
! <service name="PD"/>
to the <parent-provides> node?
Regards,
Sebastian
Hi Zachary,
Genode::Env& _env; Tutorial::Child server{_env, "server", _registry }; Tutorial::Child client{_env, "client", _registry}; Main(Genode::Env& env) : _env(env) { }
Disregard if I'm off-base here, as I'm not clear on the C++ semantics of the above... Is it guaranteed that the "env" reference above, will be initialized correctly before being passed to server/client ? I guess what I'm asking is, is the ctor init-list executed first, and the "inline" inits second, or is it the reverse ?
In my code I tend to avoid mixing both types of init in the same class, so I'm not clear on what happens if they're mixed. If that's the culprit and "env" is passed non-initialized to the children, that might explain the null-pointer crash that seems to follow. Though you mention a blockage rather than a crash, so I'm maybe just lookin at this wrong.
Cedric
[1] https://gist.github.com/zgzollers/48181fbc2dac6e51015602c6329593f9
Disregard if I'm off-base here, as I'm not clear on the C++ semantics of the above... Is it guaranteed that the "env" reference above, will be initialized correctly before being passed to server/client ? I guess what I'm asking is, is the ctor init-list executed first, and the "inline" inits second, or is it the reverse ?
I hadn't even thought about that! Thanks to your suggestion, I was able to figure out the issue. After doing to some research, I discovered C++ initializes members in the order they are declared in the class (regardless of the order they appear in the initialization list). The issue was that I was declaring the Child object in the Child_policy struct before I declared the reference to the Registry. Switching those two declarations solved the issue.
Thanks again for your help!