The same qualities that make libraries ideal for studying and reading — unfettered public access, quiet corners and nooks, minimal interaction with other people — also make them appealing places to shoot up heroin, librarians are finding.

In Norfolk, Virginia, a 47-year-old man died after a patron found him in a library restroom. In Batesville, Indiana, and New Brunswick, New Jersey, police revived others in library restrooms using a popular overdose antidote.

The body of a homeless man who frequented the Oak Park Public Library in suburban Chicago might have been there for days, fully clothed and slumped on the toilet in a restroom on the quiet third floor, before a maintenance worker unlocked it on a Monday morning in April and discovered his inglorious demise.

The empty syringe and lighter in his pockets and the cut soda can in the trash pointed to the cause, an accidental heroin overdose.

“On both a personal and a professional level, we were all very shocked and of course worried about how this could happen in our spaces,” said executive director David Seleb, who fired the security company responsible for clearing the library before closing.

The country’s heroin and painkiller problem has produced public overdoses in many places, including restaurants, gas stations, alleys and even hospitals, but the inherent attributes of public libraries leave them especially exposed. They’re free and open for whoever walks in, and lingering is welcome, no transaction or interaction required.

“People need to know that this is happening everywhere and that public libraries haven’t done anything wrong to cause it to happen in public libraries,” said Josie Parker, director of the Ann Arbor District Library in Michigan.

Her library already had removed bathroom ceilings and toilet tanks where people could hide drugs and restroom entrances that could be locked — changes made over a decade ago to curb cocaine trafficking, Parker said.

She raised drug-abuse concerns again in 2014 when officials were discussing a proposed park next to the library. Though unpleasant, starting a public discussion about drug and alcohol abuse observed at the library spurred a beneficial community response, Parker said.

These days, police routinely walk through the library, and social workers set up shop there, checking in with folks. All that, Parker said, strips away some anonymity.

“Anonymity allows people to do things they wouldn’t do otherwise in public places,” she said, “and if you can take away anonymity, you can help change behavior.”

In Ohio, peace officers from Toledo’s library system are being trained to help the sheriff’s Drug Abuse Response Team. Boston’s libraries have needle drop boxes and have offered overdose prevention training for employees and residents.

At the Humboldt County Library in Eureka, California, a librarian turned life-saver when she realized a man apparently sleeping in a chair was actually unresponsive, his lips turning blue. Health officials had provided the overdose antidote naloxone — often known by the brand name Narcan — for the library, so librarian Kitty Yancheff injected it into the man’s leg, then into a still-limp arm before he gurgled and fluttered his eyes.

“I felt grateful that we had this Narcan on hand and that we were able to save his life, but it was kind of surreal,” said Yancheff, the library’s public services division manager.

It was also a bit ironic, considering Yancheff had given a presentation titled “Librarians as First Responders” during a conference years earlier. She was talking about how libraries increasingly provide non-traditional services, such as job-search help and de facto daytime sheltering for the homeless; she hadn’t figured on overdose rescue becoming part of the job.

The American Library Association encourages librarians to get training on interacting with special populations, such as drug users and the homeless, but stresses the importance of partnering with groups such as police and social workers, said Julie Todaro, the association’s president.

“Clearly when you have the epidemic that we have and the issues with the patrons that we have, we need to organize assistance,” she said. “That doesn’t mean we ourselves provide it.”