TritonDataCenter / node-debug-school

nodeschool curriculum for debugging Node.js
MIT License
48 stars 9 forks source link

coreadm not usable anymore when a given solution script is checked #9

Closed misterdjules closed 10 years ago

misterdjules commented 10 years ago

When the following solution script of the "GENERATE CORE WHEN APP CRASHES" exercise is executed:

#!/bin/bash

mkdir -p ./my-cores
coreadm -g ./my-cores/core.%p
ulimit -c unlimited
node --abort-on-uncaught-exception node-test-crash.js 2>/dev/null

the following error message appears:

Error cleaning up:Command failed: coreadm: coreadm service not online

It seems that from that point on, coreadm cannot be used anymore, and always gives the same error message. Rebooting the instance doesn't make coreadm work.

misterdjules commented 10 years ago

There seems to be a bug with coreadm's handling of core files paths patterns. In other words, setting incorrect core files paths patterns with coreadm causes it to stop working. Even a reboot doesn't put it back in a sane state. It also seems that relative paths are considered incorrect by coreadm.

I don't know if and when it'll be fixed though, so I introduced a change that lowers the chance of having students set relative path for core files patterns.

It certainly doesn't fix the issue, but I couldn't think of anything else for now.

misterdjules commented 10 years ago

The best I can come up with right now is to sniff that the path passed to coreadm is absolute. Maybe setting a coreadm shell alias in the shell that runs the submission script would allow us to monkey-patch coreadm and exit early if the path is relative? Otherwise, we'd probably need to do some pattern matching in the code that check the submission script.

ghost commented 10 years ago

It's definitely a bug in coreadm. However, if you have the ability to intercept and test whether the path is absolute, you also have the ability to correct it and make it absolute yourself. The readlink(1) utility's -f option does exactly this -- and as a bonus, it also handles symlinks for you.

misterdjules commented 10 years ago

@wesolows Thank you for suggesting to use readlink, definitely better than to exit early!

misterdjules commented 10 years ago

Just for the record, when coreadm goes into maintenance mode is cannot be used anymore, this puts it back in a usable state:

$ svccfg -s system/coreadm:default setprop config_params/global_pattern='/some/absolute/path'
$ svcadm refresh coreadm
$ svcadm clear coreadm