Any parents of young children — or anyone thinking of hearing the pitter-patter of little feet — are urged to go to their local movie theater and see “The Glass Castle.” Not as a how-to guide, mind you. No, that might actually get you thrown in jail.

They should go see it instead as a much-needed reminder that you can mess up spectacularly with your kids and still manage to have them adore you. “The Glass Castle “ is steeped in crazy love, but love nonetheless.

Based on Jeannette Walls’ 2005 best-selling memoir, the film is both a tribute to parenting and a confessional of its absence. Like the book, it looks back without pity or sentiment. Unlike the book, it’s got Woody Harrelson and Brie Larson, acting spectacularly.

Walls created a sensation when she wrote about her destitute and nomadic youth, a childhood of hunger and privation at the hands of a pair of idiosyncratic parents who shunned schools, authority, capitalism and regular bill payments.

Hers was a childhood where she suddenly moved in the middle of the night, badly burned herself while unsupervised at the stove, had to eat butter and sugar as a meal, endured rages from her alcoholic dad and lived in homes without plumbing or electricity.

She was left in the house of an abuser to fend for herself and “learned” to swim when her father repeatedly tossed her underwater so she’d no longer cling to the side of the pool. Struggle, she was taught, gives life beauty. Adventure was more important than comfort.

“You learn from living,” her father says after steering the family’s broken-down station wagon into the unforgiving desert for a night under the stars. “Everything else is a damn lie.”

The film is directed by Destin Daniel Cretton, who co-wrote the screenplay with Andrew Lanham and reunites with Larson, who starred in his indie “Short Term 12.” It’s a mature, empathetic work of filmmaking from a young artist even if such a quirky story has a few too many grand Hollywood flourishes, as when our heroine — high heels in hand — abruptly leaves a fancy dinner to sprint to her father’s bedside amid a soaring soundtrack.

Larson plays the adult Jeanette Walls who seems to have blocked out much of her hardscrabble youth as a rising magazine writer in New York City. The movie opens like the book, with the author in a taxi in 1989 happening to spy her parents Dumpster-diving on a street in the East Village.

A series of flashbacks reveal the unique way the Walls’ four children were raised. They have an artistic, bohemian mother (an understated Naomi Watts as Rose Mary Walls) and a fiery, charismatic dad (Harrelson as Rex Walls) who promises to build a fantastic glass castle for the family to live in one day. Their father is brilliant and dashing but undependable. He offers them their own stars in the heavens for Christmas, but takes their last few dollars to get drunk. Warts and all are shown — yet very little blame.

The exact moment when dad goes from offbeat quirky to dangerous is never clear but Harrelson’s descent into a moody, angry, lying Walls — but one always loving — is riveting. A man who once promised thrilling freedom for his kids becomes their warden, refusing to let them leave for better lives. (The younger Jeannettes are played with real skill by Ella Anderson and Chandler Head).

Jeannette Walls’ story is clearly lovingly protected by the filmmakers, from the stiff shoulder pads of the 1980s to the developing darkness of the film. There’s astonishing detail rendered, down to the use of real Rose Mary Walls’ paintings on the walls and the long-gone “Please Do Not Slam the Door” stickers on yellow cab windows.

In the face of a horrific childhood, the Walls kids are fiercely protective of each other, as expected. What’s not as expected is that they still love their parents, too. Frustratingly, it’s not clear if they became happy adults because of their upbringing or despite of it, but that almost seems beside the point. The messages here are that kids are more resilient than we think, that your parents aren’t as crazy as you think, and that love always, always, wins.

‘The Glass Castle’

Rated: PG-13 for mature thematic content involving family dysfunction, and for some language and smoking.