17

It is not legal to take GPL code and re-license it under CC-BY-SA, and fair-use is settled on a case-by-case basis in the US and may change from country to country. That means that it is not known to be legal to post GPL’d code to Stack Overflow or other stack exchange sites. See, for example, here, where the consensus is that you aren’t allowed to use GPL’d code in an answer on Stack Overflow.

For answers and most questions, this isn’t a problem. If you’re the original author of the code, you can dual-license it under GPL and CC-BY-SA and implicitly do so when posting it here.

However, suppose you are having trouble with some GPL software you didn’t write. You can create an MCVE which narrows down the specific issue, but only by bisecting the existing code instead of reproducing it in a separate project.

In most cases, you could then post your MCVE to Stack Overflow along with your question. However, since the code is GPL’d, you cannot post it in the question. Since questions for debugging help must include the code in the question, this means you cannot ask your question on SO at all.

I have in fact been told that questions about GPL’d code aren’t appropriate for SO for this reason. However, that seems completely wrong: a lot of important, and complicated, code is GPL’d. Preventing people from asking about this code is limiting for the site.

Therefore, the question: what should we do about this?

I have three suggestions:

  • Relax the rules about posting GPL’d code. Allow it in questions when it seems clear it’ll qualify as fair use. This is probably safe, a) as most questions and answers probably fall under fair use*, b) most people who GPL their code are probably fine with it being put on SO or derivative works, and c) the site will probably get takedown requests before lawsuits. But if I’m wrong about both of those assumptions simultaneously (I am not a lawyer, copyright is complicated, international copyright is even more complicated, etc.), I think the site could have legal liability.
  • Allow MCVEs to be links instead of code in the question, if there’s a licensing conflict, the link is to a place which will probably last a while (GitHub, savannah.nongnu.org, kernel.org, etc), and the relevant code is easy to find on the linked page (instead of “I get compiler errors on this 3000-line file”).
  • EDIT to add: A third option is to allow portions of user-submitted content to be under other licenses than CC-BY-SA 3.0. That would probably present a technical challenge at least, and has other drawbacks; I doubt it would be worth doing, but I thought it would be worth mentioning for completeness.

  • This is similar to what Jeff Atwood said about code originally posted on SO, but that was for using code in non-SO projects. I don’t know if we should be more paranoid ourselves, or if anything relevant has changed in the last 8 years.
15
  • 45
    If you're having a problem while working on a GPL project, then construct an MCVE of the problem you're facing from scratch, as your own original work when asking the question, just like anyone with a question about proprietary code that belongs to, say, their employer, would do. If you're not able to construct your own original MCVE for the problem you have, you're not ready to ask your question yet.
    – Servy
    Dec 29, 2017 at 19:13
  • 2
    One difficulty with linking to a place which will "probably last a while" is determining which places count, noting that some places will last a while but the code posted at those places may not (code pasting sites, for example). Dec 29, 2017 at 22:05
  • 3
    @Servy While I am not a lawyer, my understanding is that this may not always be possible. For example, the MCVE of a question about GNU Readline must necessarily use functions from the GNU Readline library. Because compiling the MCVE will require linking to the GNU Readline library, the MCVE may be a "derived work" that would be covered under the GPL. I don't know whether this would be fair use, but this could be a potential issue.
    – rlee827
    Dec 29, 2017 at 23:08
  • 2
    @rlee827 In that case you are required to make your MCVE available under the GPL, but since you wrote it you can also make it available under any other license you wish, including CC-BY-SA 3.0. In fact, based on the Stack Overflow terms of use, you automatically do license it under CC-BY-SA 3.0 in addition to the GPL, so that isn’t an issue. It’s only when you didn’t write the code in question that it becomes a problem.
    – Daniel H
    Dec 29, 2017 at 23:24
  • 1
    @DanielH This is kind of making my brain hurt a bit; you're saying that if you typed a program that required GPL library X to work, that you could license that code as CC-BY-SA, and in effect it would transform into GPL only when it was compiled? That's... a fascinating loophole. It sort of sounds like you're saying that the "infectious" aspect of GPL only applies when it runs through the compiler, and the code that calls the GNU library itself may or may not have to be GPL? That doesn't sound right.
    – jrh
    Dec 30, 2017 at 1:23
  • Also there's been something I've been wondering for a while; if I in theory had a blog and put printf("Hello world!\n"); as a code snippet, and licensed that snippet as GNU GPL, does that mean that nobody could ever use that line of code again, or is there some sort of way to say, legally "This snippet is too short / too common to be licensed."
    – jrh
    Dec 30, 2017 at 1:30
  • 1
    @jrh, why doesn't it sound right? Distributing non-GPLed software as source such that users can link it to GPLed software themselves (to generate a binary that can't legally be redistributed, as it contains code under multiple incompatible licenses) is by no means unheard of. Dec 30, 2017 at 3:05
  • Uh oh, time for nobodys favorite nitpick: GNU GPL. That's what it's called. -- Also that discussion is too abstract. There won't be an official relaxation of the ToS or muddling posts with additional licensing boilerplate (which nobody bothers with anyway). You'll need a concrete example to gauge if it's non-essential/non-significant and covered by fair use.
    – mario
    Dec 30, 2017 at 11:35
  • 2
    @mario Even the FSF often just says "the GPL"; unless you know of another General Public License not associated with GNU, and you think I might be talking about that, the term is both unambiguous and in common usage including by the creators of the license. And part of the issue with concrete examples is that even the most minor of quotations doesn't necessarily count under fair use until a judge says otherwise..
    – Daniel H
    Dec 31, 2017 at 2:23
  • 1
    Isn't code now covered by MIT License rather than CC-BY-SA? Not that it changes the issue though.
    – aaron
    Dec 31, 2017 at 6:34
  • 1
    @jrh, it's actually even a little bit trickier than that, and as always with legalities, an interpretation must be made. If the code you are typing depends so much on the GPL library in question, that your code is to be viewed as derived work of the library you are using, then your code is also GPL and no "loop hole" exists. The "loop hole" exists for instance (non exhaustive list) when the library is either not affecting how your code is made that much, or when there are alternative non GPL implementations or similar libraries you could use instead. Dec 31, 2017 at 10:38
  • 1
    You are mistaken, @DanielH. In the event that one has prepared a derivative of a work licensed to oneself under the GPL (only), no, you cannot convey your derivative to others under any license but the GPL. Such a work does not belong fully to you -- that's the significance of it being a derivative, and it's why complying with the GPL requires that you license your derivative under the GPL when you convey it. The GPL furthermore expressly denies that it grants permission to convey such derivatives under any other license. Jan 1, 2018 at 4:19
  • @JohnBollinger As I understand it, only the compiled program counts as a derivative work; if I write a short MCVE for a readline issue, that's entirely my work except arguably the line #include <readline/readline.h> which is purely functional. You can't distribute the compiled product on SO, and every line in the MCVE would have been written by me.
    – Daniel H
    Jan 1, 2018 at 20:28
  • 1
    No, @DanielH. The GPL is a copyright license covering (usually) source code as the primary protected material. The corresponding compiled program or library certainly is a derivative work, but even more importantly for the GPL's purposes, so also is any modified version of the source code. This is not at all controversial, and the GPL's effectiveness depends on it. Jan 1, 2018 at 20:54
  • @JohnBollinger Obviously that's the case for "modified versions of the source code". My comment was about if you were writing a completely different program which used readline, which isn't the same thing. It might count as a derived work even in source code form (I'm still not sure on that part, since all it uses is the interface and I think the FSF's position is that an API shouldn't be copyrightable), but it definitely isn't a modified version of the library.
    – Daniel H
    Jan 2, 2018 at 1:38

2 Answers 2

5
  • Relax the rules about posting GPL’d code. Allow it in questions when it seems clear it’ll qualify as fair use. This is probably safe, a) as most questions and answers probably fall under fair use*, b) most people who GPL their code are probably fine with it being put on SO or derivative works, and c) the site will probably get takedown requests before lawsuits. But if I’m wrong about both of those assumptions simultaneously (I am not a lawyer, copyright is complicated, international copyright is even more complicated, etc.), I think the site could have legal liability.

This is not possible. The rules about posting GPL'd code are defined by the GPL itself and copyright law - you can't post it here not because of rules that Stack Overflow has made, but because it's illegal to do so.

To expand on that: as you said, the author of the code is free to post their code here. This is because they hold all rights to the code, and are permitted to do whatever they wish with it, including offering it under multiple licenses as they do when posting it here. Any party that does not hold copyright in the work has only the rights given to them by the license applied to the work - in this case, the GPL (read: you can only do what the GPL allows you to). The GPL does not allow you to redistribute the covered work under any other license. By posting it here, that's what you're doing, which voids your rights under the license.


Your second suggestion - to relax the rules around MCVEs being included in the question - is more plausible, but brings with it all the problems that arise when the MCVE is external - link rot (you addressed that to an extent, but it's still an issue), firewalls and proxies, etc etc.

Personally, that's not a compromise I'd be happy with. Communicating the requirements of external MCVEs to new users and enforcing the standards is not only difficult, it's an extra workload for both community moderation and the diamond moderators. Unfortunately, I believe the status quo has to remain - unless you can (a) get permission from the copyright holder to post an MCVE here, or (b) create an MCVE covered by fair use, then Stack Overflow is not the place for the question.

12
  • 10
    "Covered by fair use" isn't necessarily even a concern -- if a sample truly meets the MCVE definition, it contains only components which are mandated by functional concerns and no unnecessary expressive elements; only expressive elements are subject to copyright, and these (comments, strings to be printed, &c) should be written to best showcase the problem, not as given in the original context or code. So, bottom-line, fair use shouldn't be necessary, because there should be no copyright violation to require fair-use exemptions. Dec 29, 2017 at 22:20
  • 1
    @CharlesDuffy I wouldn't be entirely comfortable even then; law is messy when it comes to what elements of software are eligible for copyright. UK copyright law leans towards covering all elements of a unique creation, which would include non-expressive elements provided the work as a whole is an expressive creation, so to speak.
    – ArtOfCode
    Dec 29, 2017 at 22:25
  • Granted -- I'm only familiar with US law on this matter. Dec 29, 2017 at 22:26
  • @CharlesDuffy You’d think, but the current status of Oracle v. Google implies that doesn’t go as far as you’d hope. There’s also the worry that something isn’t actually necessary as part of a minimal example, but the asker isn’t capable of determining that (if they understood the problem enough to guarantee minimality, they could probably fix the issue themself).
    – Daniel H
    Dec 29, 2017 at 22:40
  • 10
    The GPL doesn’t allow you to post the copyrighted work or derivatives, but it does not—and cannot—prevent fair use. If the site (the actual company, not the community) decided that it would assume anything which fits in the limited size a question gives, and otherwise meets the criteria of a good question, qualified as fair use, then you would be allowed to post GPL’d code here in questions. This would remain the case until somebody successfully argued that some usage wasn’t fair, or more likely just submitted a takedown request and a moderator removed the code without going to court.
    – Daniel H
    Dec 29, 2017 at 22:44
  • I am not a lawyer, but my understanding is that a court really would find any use in a question to be fair (as long as it was a valid question in other respects, not just posting the code in the “question” field). If Stack Exchange, Inc’s lawyers agreed with that analysis and were willing to take the risk it was wrong, the site rules would allow posting code in questions regardless of the original license of the code, and as long as the analysis actually is correct nobody would be doing anything illegal.
    – Daniel H
    Dec 29, 2017 at 22:49
  • 1
    @DanielH "If the site decided anything which fits in a question qualified as fair use..." Again, that's not a decision that SE can take. That distinction is a legal distinction, not one that's subject to individual entities' rulings on it. Fair use is fair use is fair use, no matter where or what site you're talking about it on - it means the same thing everywhere.
    – ArtOfCode
    Dec 29, 2017 at 22:57
  • 5
    @ArtOfCode It’s not well-defined legally what is and is not fair use (in the US); it’s decided on a case-by-case basis. I’m saying that the site’s lawyers could look at what guidelines do exist and decide that, to the best of their understanding, anything that otherwise fits the site’s rules would also fit the guidelines of fair use. If, hypothetically, fair use were well defined and included that any excerpt less than 30,000 characters definitely qualified (which would be ridiculous, but it’s an example), the lawyers could definitely decide that anything posted to SO was fair use.
    – Daniel H
    Dec 29, 2017 at 23:03
  • 1
    @DanielH: "I’m saying that the site’s lawyers could ... decide that...". Yes, but lawyers don't decide these things, courts do. Suppose SO lawyers do make such a determination, and you post some code that a copyright holder believe is infringing. They send a takedown order ... and ... then what? SO ignores the order? SO takes on the copyright holder on your behalf? Dec 31, 2017 at 15:56
  • 1
    @JamesKPolk Presumably SO then takes down my post because, even though they don't think it's infringing it's definitely not worth fighting over in court. Lawyers do decide, based on their beliefs about what courts decide, what they recommend a company does in particular situations.
    – Daniel H
    Dec 31, 2017 at 21:19
  • 1
    @JamesKPolk (Or in general situations, like with "Stuff with a license incompatible with CC-BY-SA".) I'm saying I'd like that recommendation be "Assume it's good in ambiguous situations until the copyright holder complains", not "Assume it's bad in ambiguous situations (i.e., all of them where there isn't an explicit license from the copyright holder allowing this)".
    – Daniel H
    Dec 31, 2017 at 21:29
  • 1
    @DanielH: Well, that's basically the status quo then. The poster is responsible for not posting infringing content, the site is responsible for being responsive to DMCA takedown orders, your contributions are CC-BY-SA or whatever as long as you are the owner of the content, and copyright holders are responsible for policing their works. I don't think there is any satisfying answer available unfortunately. Dec 31, 2017 at 21:47
-1

Agreeing with OP and all purely imo:

The rules for fair use may be decided case-by-case, but there are many decades of precedent now, and "anybody can sue anybody for anything" applies no more strongly to GPL'd code than to any other code.

Specifically, if you're posting excerpts of a work, how much of the original work you post, and the reason for ("purpose and character of") your post, and the effect on the market for the original, are almost certainly all going to weigh extremely heavily in your favor should someone be asinine enough to make an issue of it.


@AoC's comment above, which I will not quote to avoid giving the assertions any more prominence, (a) is simply false (see the first link above) and (b) even if it were true, if everyone who looks at a post regards the purpose and character of the excerpt as an attempt to understand some aspect of the original work and so incomplete as to be unusable as a substitute for the original work, then the other two criteria follow inescapably from that unusability and the use wholly satisfies all four statutory criteria, making it fair use, and not copyright infringement at all, by statute declaration.

Nobody can weigh risks for SO's corporate legal staff, they get to do that themselves. But undefended rights will be lost, and I believe they have an obligation to incur some risk of being targeted for barratry in order to defend fair use against that sort of predator.

3
  • I think that as long as they a vigilant about take downs when requested they are fine (assuming people re not posting more than about 30 lines.
    – Elin
    Jan 1, 2018 at 2:45
  • Sorry for being dense but ArtOfCode's comment you linked to contains three sentences. Which specific point are you claiming is false? Jan 2, 2018 at 23:51
  • @JamesKPolk the notion that there's some mystical Oracle Of Legalese that objectively decides what's fair use and what isn't. The borders will always be broad and very fuzzy, because that's the nature of language and motivation and culture, always relevant in human endeavours. But that doesn't affect the core here, there are some things I claim everybody of sound mind will regard as fair. Posting a few lines of GPL'd code to ask interpretation/use quite simply is fair, even if some unspeakable lowlifes might decide to sue over it.
    – jthill
    Jan 3, 2018 at 5:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .