scripts/kernel-doc crashes (undeclared variable)

Bug #2072145 reported by AnthonyKirby
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
linux (Ubuntu)
Confirmed
Undecided
Unassigned
linux-kernel-headers (Ubuntu)
New
Undecided
Unassigned

Bug Description

/usr/src/linux-headers-5.4.0-187/scripts/kernel-doc has a syntax/compilation error, which makes the script fail.

To reproduce:
- install linux-headers-5.4.0-187
- run /usr/src/linux-headers-5.4.0-187/scripts/kernel-doc

What should happen:
- should print usage doc

What happens:
- fails with error
```
Global symbol "$args" requires explicit package name (did you forget to declare "my $args"?) at /usr/src/linux-headers-5.4.0-187/scripts/kernel-doc line 1089.
Global symbol "$args" requires explicit package name (did you forget to declare "my $args"?) at /usr/src/linux-headers-5.4.0-187/scripts/kernel-doc line 1089.
Execution of /usr/src/linux-headers-5.4.0-187/scripts/kernel-doc aborted due to compilation errors.
```

Details about the syntax error:
- this is a regression since package linux-headers-5.4.0-182: script /usr/src/linux-headers-5.4.0-182/scripts/kernel-doc works OK & prints usage doc
- the error message is a clear representation of the problem : in function "dump_struct($$)", "args" has not been declared when used at line 1089

What was I doing that made me notice this?:
- building a DKMS module; the module failed to build on this kernel version.

Why do I care?
- I had to patch the script in linux-headers in order to build a DKMS module. It's clearly a bug in the kernel-doc script (being an undeclared variable), not a bug in the DKMS module. I'm keen not to have to patch linux-headers-<$future-version> in order to support the deployment of the DKMS module in my organisation.

How do I think this happened?
- looking at current kernel source:
- - "my $args" declared at https://github.com/torvalds/linux/blob/master/scripts/kernel-doc#L1160
- - "$members =~ s/(?:__)?DECLARE_FLEX_ARRAY\s*\($args,\s*$args\)/$1 $2\[\]/gos;" referenced at https://github.com/torvalds/linux/blob/master/scripts/kernel-doc#L1172
- I suspect that the usage line was cherry-picked, but the refactor to use $args hadn't been merged
- i.e. something like https://github.com/torvalds/linux/commit/3080ea5553cc909b000d1f1d964a9041962f2c5b was cherry-picked, but relied on a refactor in https://github.com/torvalds/linux/commit/e86bdb24375a810ea7993d64ed406a803db71225

How to fix?
- the simple fix would be remove lines 1088 & 1089, i.e. revert to linux-headers-5.4.0-182
- add a check that this script is valid, run for future builds (given that it's not otherwise covered)

Revision history for this message
AnthonyKirby (a3thony) wrote :

Also affects kernel 5.4.0-189

summary: - scripts/kernel-doc undeclared variable
+ scripts/kernel-doc crashes (undeclared variable)
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in linux (Ubuntu):
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.