Oh no! It looks like you've found a bug!
Here's how to take care of this pesky critter:
1) Check in the Drupal watchdog and civicrm log files for messages that occurred around about the same time as the contribution.
2) Establish if the contact was created in CiviCRM (your post doesn't explicitly say it was). If so, is it tied to the contribution and Drupal user?
3) If the answer to the above is yes, establish if you can create memberships on that user with the CiviCRM api.
4) If the answer to 3) is yes, then it should be possible to establish where in the code the critter is, put breakpoints around it (or use debug output or die commands) to establish where the error is. Finding out what parameters are going in is usually the thing to do here - so many times SQL queries end up trying to insert an illegal empty string or similar.
When you have that information, you have enough to file a bug report with the core team!
Hope that helps,
John