(CNN) Roseanne Barr blamed the sleep aid Ambien for a series of racist tweets that resulted in the cancellation of her show "Roseanne" by ABC on Tuesday.

Barr tweeted, "guys I did something unforgiveable so do not defend me. It was 2 in the morning and I was ambien tweeting."

In another tweet, Barr doubled down, saying that she has "done weird stuff while on ambien-cracked eggs on the wall at 2am etc --"

Ashleigh Koss, a spokeswoman for the North America region of Sanofi, the maker of Ambien, said in a written statement Wednesday, "While all pharmaceutical treatments have side effects, racism is not a known side effect of any Sanofi medication."

People of all races, religions and nationalities work at Sanofi every day to improve the lives of people around the world. While all pharmaceutical treatments have side effects, racism is not a known side effect of any Sanofi medication.

The claim drew questions and backlash from social media, with one writer and correspondent for the TV show "Full Frontal with Samantha Bee" saying, "Ambien makes you racist? No wonder some of y'all can't get woke."

Ambien makes you racist? No wonder some of y'all can't get woke. 😛

As for whether Ambien could be to blame for Barr's actions, Dr. Nancy Collop, medical director of the Emory Sleep Center, wrote in an email, "I really don't think so."

"Writing a coherent tweet is not what is usually seen" during abnormal sleep behavior, she said. In contrast, the types of movements you'd expect to see, like walking or eating during sleep, "don't require a lot of thought."

"I wouldn't say it is impossible but I think her history of prior racist comments suggests conscious decisions were made ... not related to the use of a drug," Collop said.

Another sleep researcher said she has encountered some patients who have texted in their sleep. These patients "may send things that don't make sense," Dr. Rachel Salas, associate professor of neurology in the sleep medicine division at Johns Hopkins Medicine, wrote in an email. "But some have sent coherent texts without remembering."

"Ambien does not induce 'racist tweets,' " she added, "but it is possible that people could text or tweet while on Ambien and not remember.

"My advice for people is not to sleep with your phone or electronics near your bed when on sleep aids, and to put a passcode on your phone to make it more difficult to send texts, tweets, or make purchases."

A hard pill to swallow?

The drug has also been a controversial defense in many legal cases.

In 2010, a man accused of disrupting a trans-Atlantic flight by claiming he was carrying explosives also told the federal marshal onboard that he had taken Ambien, according to court documents. Doctors said at the time that it was very unlikely that the drug was the cause.

"In a person experiencing confusional arousal because of Ambien, you wouldn't expect to hear comments from that person that seem to fit into the context of the environment that they are in," said Dr. Michel Cramer Bornemann, a lead investigator of Sleep Forensics Associates. "In this case, a man on board a plane is talking about false passports, bombs, dynamite and blowing up a plane. This seems really at first glance, inconsistent with what we know of Ambien's side effects."

Ambien, also known by the generic name zolpidem, is a prescription drug used to treat insomnia that was approved in 1992 by the US Food and Drug Administration. It belongs to a class of medications called sedative-hypnotics.

The drug has a number of side effects including "abnormal thinking and behavioral changes," which may take the form of "decreased inhibition" such as aggressiveness and extroversion that seem "out of character," according to information that comes with the drug. Hallucinations have also been reported, representing less than 1% of adults in controlled trials for insomnia.

Researchers have found high levels of zolpidem in the blood of some patients the morning after a dose -- so much so, it could affect their cognitive and driving skills. This prompted the FDA to lower recommended dosages for certain people in 2013.

There have been reports of "complex behaviors": cooking and eating food, making phone calls, having sex and driving. The risk of these behaviors may increase at higher doses and in combination with alcohol or other drugs, experts say.

Still, these behaviors "are not 'common,' " Collop said. But even if fewer than 1% of patients experience these symptoms, she added, that would add up to a lot of people, given how common the medication is.

These behaviors "have been reported in patients who are not fully awake after taking a sedative-hypnotic," drug information documents say. "Patients usually do not remember these events.

Follow CNN Health on Facebook and Twitter See the latest news and share your comments with CNN Health on Facebook and Twitter.

"It can rarely be determined with certainty whether a particular instance of the abnormal behaviors listed above is drug induced, spontaneous in origin, or a result of an underlying psychiatric or physical disorder. Nonetheless, the emergence of any new behavioral sign or symptom of concern requires careful and immediate evaluation."