Tims_blog_2026-04-25_16:01:26.25 

TB Wiki

Login

Tims blog 2026-04-25 16:01:26.25


Subject
AI makes copy-paste errors
Date
2026-04-25_16:01:26.25
Tags
Linux, ai, coding
Author
tbird20d

I recently submitted a patch to the Linux kernel that included some assembly code for accessing clock hardware early in kernel initialization. Another developer gave some feedback indicating that I should preface the clock access instructions with memory barrier instructions, to avoid race conditions with other code. However, my code only runs before SMP starts, so it's not possible for such a race condition to occur.

I suspect the developer either copied the code from somewhere else, or used AI to generate the code for the assembly instructions that he suggested.

After thinking about this, it occurred to me that the most likely type of errors that AI is going to make in creating new code are "copy-paste" errors. These are a type of error where code is copied from one place and used in another place, but the conditions in the new place are different, either syntactically or semantically. AI seems adept at handling syntactic differences, such as indenting the code properly or renaming variables.

But it's not intelligent enough to handle different semantics in complex situations. If the human doesn't have the experience to detect such things , which can often be quite subtle, then it results in "copy-paste"-type bugs, where the current code is incorrect or sub-optimal for its current location.

This problem is due to LLMs and AI coders being able to pull stuff from their training data, but not actually understand the code at a deeper level. But AI coders are getting better and better, and they already detect subtle problems that the average or even experienced coder might miss.

TBWiki engine 1.9.3 by Tim Bird