Re: oldconfig loop infinitely with a hex/int config without valid default and a closed stdin

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 7/30/23 10:59, Masahiro Yamada wrote:
> On Sat, Jul 29, 2023 at 12:23 AM Yoann Congal <yoann.congal@xxxxxxxx> wrote:
>> Hi,

Hi,

>> While analyzing a Yocto bug[0] I think I've identified a problem in kconfig.
>> The problem happens if you have a hex or int type config without a default value.
>> Like this :
>>   config TEST_KCONFIG
>>         hex "Test kconfig"
>>         # No default value
>> ... and try to start oldconfig with a closed stdin (like we have in Yocto):
>>   echo -n "" | make oldconfig
>>
>> When this happens, oldconfig prompts for the value of TEST_KCONFIG but stdin is closed it get the global default value : an empty string. This is not a valid hex/int value so it prompts again, hence the infinite loop.
>>
>> I'm having trouble pointing where the bug is exactly :
>> * Should the global default value for hex/int be valid in their context? (like the minimal value of the range or 0/0x0)
>> * Must all int/hex config provide a valid default value? (This is the case for hex config in the kernel). This would have to be documented somewhere (Some other KConfig implementation did [1])
> 
> Presumably, it is reasonable to require explicit 'default' for int/hex.
> 
> Most of the int/hex entries in Linux are already doing it.

Shouldn't this be documented somewhere? (Sorry if it already is, I could not find it)

>> * Should all oldconfig/syncconfig/... exit with an error when trying to prompt on a closed stdin? (I might be able to send a patch for this one)
> 
> No.
> I have seen multiple scripts piping the 'yes' command to Kconfig.
> There is no reason to prohibit pipe or redirection.

I agree, I would not want to prohibit pipe or redirection.

I'm specifically talking about a *closed* stdin. A closed stdin is a case were we're 100% sure that we'll never get a valid value. This is why I propose the following check :
- closed stdin
- default value is not valid (eg "" for a hex or int)
If these two conditions are true when prompting, then exit with an error instead of what happens currently : starting an infinite loop.

Would you accept something like this?


> I think the fastest fix is to send a patch to U-Boot
> to add a default for CONFIG_DEBUG_UART_BASE
> (and more patches if there are other similar cases).

Ok, I will try to do that.

>> [0]: https://bugzilla.yoctoproject.org/show_bug.cgi?id=14136
>> [1]: https://docs.zephyrproject.org/1.14.0/guides/kconfig/index.html#redundant-defaults

Thanks!
-- 
Yoann Congal
Smile ECS - Tech Expert



[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux