Tims blog 2026-04-25 16:01:26.25 in split format
| ----; 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 assemblycode for accessing clock hardware early in kernel initialization. Anotherdeveloper gave some feedback indicating that I should preface the clockaccess instructions with memory barrier instructions, to avoid race conditionswith other code. However, my code only runs before SMP starts, so it's notpossible for such a race condition to occur. | ----; 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 assemblycode for accessing clock hardware early in kernel initialization. Anotherdeveloper gave some feedback indicating that I should preface the clockaccess instructions with memory barrier instructions, to avoid race conditionswith other code. However, my code only runs before SMP starts, so it's notpossible for such a race condition to occur. |
| I suspect the developer either copied the code from somewhere else, or usedAI to generate the code for the assembly instructions that he suggested. | I suspect the developer either copied the code from somewhere else, or usedAI 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 usedin another place, but the conditions in the new place are different, eithersyntactically or semantically. AI seems adept at handling syntactic differences,such as indenting the code properly or renaming variables. | 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 usedin another place, but the conditions in the new place are different, eithersyntactically 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 complexsituations. 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. | But it's not intelligent enough to handle different semantics in complexsituations. 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 theirtraining data, but not actually understand the code at a deeper level. ButAI coders are getting better and better, and they already detect subtle problemsthat the average or even experienced coder might miss. | This problem is due to LLMs and AI coders being able to pull stuff from theirtraining data, but not actually understand the code at a deeper level. ButAI coders are getting better and better, and they already detect subtle problemsthat the average or even experienced coder might miss. |