Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SerialPort doneAction never called & port not properly closed? #434

Closed
redFrik opened this issue Aug 26, 2012 · 24 comments
Closed

SerialPort doneAction never called & port not properly closed? #434

redFrik opened this issue Aug 26, 2012 · 24 comments
Labels
bug Issues that relate to unexpected/unwanted behavior. Don't use for PRs. comp: sclang sclang C++ implementation (primitives, etc.). for changes to class lib use "comp: class library"
Milestone

Comments

@redFrik
Copy link
Contributor

redFrik commented Aug 26, 2012

closing a serial port does not call its doneAction and probably not prDoneAction either.

a= SerialPort("/dev/tty.usbmodemfa131", 9600)
a.doneAction= {"now".postln}; //should post this when works
a.close //or SerialPort.closeAll

this works in old sc3.4.4, but is now broken in sc3.5.1, sc3.5.2, sc3.5.4 and sc3.6 (on my mac osx 10.6.8).

and another thing noted is that the below lines...
"SerialPort /dev/tty.usbmodemfa131 was closed
SerialPort Cleanup"
aren't posted when the doneAction fails. this could mean that the port isn't properly closed.

@timblechmann
Copy link
Contributor

should be fixed

@sensestage
Copy link
Contributor

fix was wrong though.
The doneAction should be called as soon as the port is actually closed by the primitive, and also when the port closes for another reason (e.g. when a device got unplugged).
I'll test here on Linux and see if I can reproduce the bug.

@sensestage
Copy link
Contributor

The actual error happens in
PyrSerialPrim.cpp: line 430:

void SerialPort::doneAction()
{
int status = lockLanguageOrQuit(m_running);
if (status == EINTR)

For some reason status equals EINTR.
I'm not sure what that means though.

@jleben
Copy link
Member

jleben commented Sep 20, 2012

void SerialPort::doneAction()
{
int status = lockLanguageOrQuit(m_running);
if (status == EINTR)

For some reason status equals EINTR.
I'm not sure what that means though.

A system call (probably the one to lock the mutex), has been interrupted by a signal.
Usually, what you wanna do is simply retry that system call.

@timblechmann timblechmann reopened this Sep 20, 2012
@sensestage
Copy link
Contributor

On Thursday 20 September 2012 09:16:24 Jakob Leben wrote:

void SerialPort::doneAction()
{
int status = lockLanguageOrQuit(m_running);
if (status == EINTR)

For some reason status equals EINTR.
I'm not sure what that means though.

A system call (probably the one to lock the mutex), has been interrupted by
a signal. Usually, what you wanna do is simply retry that system call.

Does it matter whether the function gets passed true or false?

Should I just make a while loop, which keeps trying to obtain the lock, until
it gets it, rather than the early return from the function it does now?

sincerely,
Marije

@timblechmann
Copy link
Contributor

void SerialPort::doneAction()
{
int status = lockLanguageOrQuit(m_running);
if (status == EINTR)

For some reason status equals EINTR.
I'm not sure what that means though.

A system call (probably the one to lock the mutex), has been interrupted by
a signal. Usually, what you wanna do is simply retry that system call.

Does it matter whether the function gets passed true or false?

yes (check the sources). if it is true, it acquires the lock, if
`false', it works as a barrier (acquires the lock and releases it).

Should I just make a while loop, which keeps trying to obtain the lock, until
it gets it, rather than the early return from the function it does now?

no: that's what this method is supposed to do

@sensestage
Copy link
Contributor

Hiho,

On Thursday 20 September 2012 12:46:18 Tim Blechmann wrote:

void SerialPort::doneAction()
{
int status = lockLanguageOrQuit(m_running);
if (status == EINTR)

For some reason status equals EINTR.
I'm not sure what that means though.

A system call (probably the one to lock the mutex), has been interrupted
by a signal. Usually, what you wanna do is simply retry that system
call.

Does it matter whether the function gets passed true or false?

yes (check the sources). if it is true, it acquires the lock, if
`false', it works as a barrier (acquires the lock and releases it).

So, if you want the lock to be acquired, you should pass it true?
Just trying to get the semantics right to understand how it is used...
Since you were calling it several times in the code with the m_running
variable, without apparently taking into account where and why the m_running
variable is changed.

Should I just make a while loop, which keeps trying to obtain the lock,
until it gets it, rather than the early return from the function it does
now?

no: that's what this method is supposed to do

ok.
and then it locks up, and we'll need to figure out why.

I will then also check tomorrow whether you made similar changes to the MIDI
and LID sources when you made these changes... especially for the latter I
hope that the doneAction mechanism did not get broken...

sincerely,
Marije

@timblechmann
Copy link
Contributor

yes (check the sources). if it is true, it acquires the lock, if

`false', it works as a barrier (acquires the lock and releases it).
So, if you want the lock to be acquired, you should pass it true?
Just trying to get the semantics right to understand how it is used...
Since you were calling it several times in the code with the m_running
variable, without apparently taking into account where and why the m_running
variable is changed.

iirc, we introduced this flag to avoid a deadlock when trying to lock
the language, while it should stop running. would all be much cleaner if
invoking the language would be done from the main thread instead of the
helper thread, but that would require adding a message queue or the like

Should I just make a while loop, which keeps trying to obtain the lock,
until it gets it, rather than the early return from the function it does
now?

no: that's what this method is supposed to do
ok.
and then it locks up, and we'll need to figure out why.

just examine the state of all threads (dump all backtraces) and we will
know more

@sensestage
Copy link
Contributor

Hiho,

gdb> bt full

#0  0x00196416 in __kernel_vsyscall ()
No symbol table info available.
#1  0x00157619 in __lll_lock_wait () from /lib/i386-linux-gnu/libpthread.so.0
No symbol table info available.
#2  0x00152f7d in _L_lock_708 () from /lib/i386-linux-gnu/libpthread.so.0
No symbol table info available.
#3  0x00152dc3 in pthread_mutex_lock ()
   from /lib/i386-linux-gnu/libpthread.so.0
No symbol table info available.
#4  0x080f3802 in lock (this=<optimized out>)
    at /home/nescivi/git/supercollidergit/supercollider/include/lang/SC_LanguageClient.h:148
No locals.
#5  QtCollider::LangClient::doSchedule (this=0xbfaafea0)
    at /home/nescivi/git/supercollidergit/supercollider/QtCollider/LanguageClient.cpp:64
        t = <optimized out>
        next = <optimized out>
#6  0x00c8a994 in QObject::event(QEvent*) ()
   from /usr/lib/i386-linux-gnu/libQtCore.so.4
No symbol table info available.
#7  0x02829d84 in QApplicationPrivate::notify_helper(QObject*, QEvent*) ()
   from /usr/lib/i386-linux-gnu/libQtGui.so.4
#8  0x0282f133 in QApplication::notify(QObject*, QEvent*) ()
   from /usr/lib/i386-linux-gnu/libQtGui.so.4
No symbol table info available.
#9  0x00c7219e in QCoreApplication::notifyInternal(QObject*, QEvent*) ()
   from /usr/lib/i386-linux-gnu/libQtCore.so.4
No symbol table info available.
#10 0x00ca2c10 in ?? () from /usr/lib/i386-linux-gnu/libQtCore.so.4
No symbol table info available.
#11 0x00ca0155 in ?? () from /usr/lib/i386-linux-gnu/libQtCore.so.4
No symbol table info available.
#12 0x0848225f in g_main_context_dispatch ()
   from /lib/i386-linux-gnu/libglib-2.0.so.0
No symbol table info available.
#13 0x08482990 in ?? () from /lib/i386-linux-gnu/libglib-2.0.so.0
No symbol table info available.
#14 0x08482c2a in g_main_context_iteration ()
   from /lib/i386-linux-gnu/libglib-2.0.so.0
No symbol table info available.
#15 0x00ca0ada in QEventDispatcherGlib::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) () from /usr/lib/i386-linux-gnu/libQtCore.so.4
No symbol table info available.
#16 0x028e1e7a in ?? () from /usr/lib/i386-linux-gnu/libQtGui.so.4
#20 0x0816e396 in SC_TerminalClient::run (this=0xbfaafea8, argc=0, 
    argv=0xbfab0074)
    at /home/nescivi/git/supercollidergit/supercollider/lang/LangSource/SC_TerminalClient.cpp:276
        opt = @0xbfaafec8
        codeFile = 0x0
#21 0x080f3690 in QtCollider::run (argc=4, argv=0xbfab0064)
    at /home/nescivi/git/supercollidergit/supercollider/QtCollider/LanguageClient.cpp:40
        app = {<QObject> = {<No data fields>}, <SC_TerminalClient> = {
    <SC_LanguageClient> = {_vptr.SC_LanguageClient = 0x826a154, 
              static s_interpretCmdLine = 0xb76f2b70, 
              static s_interpretPrintCmdLine = 0xb76f2b90, 
static s_run = 0xb76ec870, static s_stop = 0xb76f2bb0, 
              mName = 0x9492210 "sclang", mPostFile = 0x0, mScratch = {
                mCapacity = 256, 
                mPtr = 0x94b0cb0 "041\003\060\064\061\003H\t", 
                mData = 0x94b0cb0 "041\003\060\064\061\003H\t"}, 
              mRunning = true, static gInstance = 0xbfaafea8, 
              static gInstanceMutex = {mutex = {__data = {__lock = 0, 
                    __count = 0, __owner = 0, __kind = 0, __nusers = 0, {
                      __spins = 0, __list = {__next = 0x0}}}, 
                  __size = '\000' <repeats 23 times>, __align = 0}}}, 
            mShouldBeRunning = true, mReturnCode = 0, 
            mOptions = {<SC_LanguageClient::Options> = {mMemSpace = 2097152, 
                mMemGrow = 262144, mPort = 57120, 
                mRuntimeDir = 0xbfab0b8d "/home/nescivi/SuperCollider/"}, 
              mLibraryConfigFile = 0x0, mDaemon = false, mCallRun = false, 
              mCallStop = false, mArgc = 0, mArgv = 0xbfab0074}, 
            mSignalMutex = {__data = {__lock = 0, __count = 0, __owner = 0, 
                __kind = 0, __nusers = 0, {__spins = 0, __list = {
                    __next = 0x0}}}, __size = '\000' <repeats 23 times>, 
              __align = 0}, mCond = {__data = {__lock = 0, __futex = 0, 
                __total_seq = 0, __wakeup_seq = 0, __woken_seq = 0, 
                __mutex = 0x0, __nwaiters = 0, __broadcast_seq = 0}, 
              __size = '\000' <repeats 44 times>, "$#1\003", __align = 0}, 
mInputBuf = {mCapacity = 1280, 
              mPtr = 0x986a13a "close;\flPort.new( \"/dev/ttyUSB0\", 9600 )\fdgets')\033Emacs.lispPerformCommand('documentNew', [ 3 ], false)\033Emacs.lispPerformCommand('documentSetProperty', [ 3, 'prSetTitle', \"*SCLang:PostBuffer*\" ], false"..., 
              mData = 0x986a138 "a\fclose;\flPort.new( \"/dev/ttyUSB0\", 9600 )\fdgets')\033Emacs.lispPerformCommand('documentNew', [ 3 ], false)\033Emacs.lispPerformCommand('documentSetProperty', [ 3, 'prSetTitle', \"*SCLang:PostBuffer*\" ], fal"...}, mInputCtlPipe = {12, 13}, mInputThread = 2981194608, mInputMutex = {
              __data = {__lock = 0, __count = 0, __owner = 0, __kind = 0, 
                __nusers = 0, {__spins = 0, __list = {__next = 0x0}}}, 
              __size = '\000' <repeats 23 times>, __align = 0}, mInputCond = {
              __data = {__lock = 0, __futex = 0, __total_seq = 0, 
                __wakeup_seq = 0, __woken_seq = 0, __mutex = 0x0, 
                __nwaiters = 0, __broadcast_seq = 0}, 
              __size = '\000' <repeats 44 times>, ":\000\000", __align = 0}}, 
          static staticMetaObject = {d = {superdata = 0x830a380, 
              stringdata = 0x826a1c0 "QtCollider::LangClient", 
              data = 0x826a200, extradata = 0x0}}, appClockTimer = {
            id = 251658242}}

#22 0x080e315b in main (argc=4, argv=0xbfab0064)
    at /home/nescivi/git/supercollidergit/supercollider/lang/LangSource/cmdLineFuncs.cpp:40
No locals.

@timblechmann
Copy link
Contributor

(reformatted via markdown to make it readable)

ok, this is one backtrace, but we'd need the state of all threads via thread apply all bt full.

@sensestage
Copy link
Contributor

building without QtCollider and without scide:

#0 0x00507416 in __kernel_vsyscall ()
No symbol table info available.
#1 0x0018e619 in __lll_lock_wait () from /lib/i386-linux-gnu/libpthread.so.0
No symbol table info available.
#2 0x00189f7d in _L_lock_708 () from /lib/i386-linux-gnu/libpthread.so.0
No symbol table info available.
#3 0x00189dc3 in pthread_mutex_lock ()
from /lib/i386-linux-gnu/libpthread.so.0
No symbol table info available.
#4 0x080bd3d2 in lock (this=)
at /home/nescivi/git/supercollidergit/supercollider/include/lang/SC_LanguageClient.h:148
No locals.
#5 SC_TerminalClient::commandLoop (this=0xbfc1021c)
at /home/nescivi/git/supercollidergit/supercollider/lang/LangSource/SC_TerminalClient.cpp:413
secs = 1348233441.3246291
sig = 2
haveNext = true
nextAbsTime = {tv_sec = 1348233441, tv_nsec = 324629068}
#6 0x080bdd56 in SC_TerminalClient::run (this=0xbfc1021c, argc=0,
argv=0xbfc103c4)
at /home/nescivi/git/supercollidergit/supercollider/lang/LangSource/SC_Termi
nalClient.cpp:276
opt = @0xbfc1023c
codeFile = 0x0
#7 0x080ac297 in main (argc=4, argv=0xbfc103b4)
at /home/nescivi/git/supercollidergit/supercollider/lang/LangSource/cmdLineFuncs.cpp:43
app = {<SC_LanguageClient> = {_vptr.SC_LanguageClient = 0x81c8348,
static s_interpretCmdLine = 0xb76cfb70,
static s_interpretPrintCmdLine = 0xb76cfb90,
static s_run = 0xb76c9870, static s_stop = 0xb76cfbb0,
mName = 0x865ec30 "sclang", mPostFile = 0x0, mScratch = {
mCapacity = 256, mPtr = 0x86a1180 "85z",
mData = 0x86a1180 "85z"}, mRunning = true,
static gInstance = 0xbfc1021c, static gInstanceMutex = {mutex = {
__data = {__lock = 0, __count = 0, __owner = 0, __kind = 0,
__nusers = 0, {__spins = 0, __list = {__next = 0x0}}},
__size = '\000' <repeats 23 times>, __align = 0}}},
mShouldBeRunning = true, mReturnCode = 0,
mOptions = {<SC_LanguageClient::Options> = {mMemSpace = 2097152,
mMemGrow = 262144, mPort = 57120,
mRuntimeDir = 0xbfc10b8d "/home/nescivi/SuperCollider/"},
mLibraryConfigFile = 0x0, mDaemon = false, mCallRun = false,
mCallStop = false, mArgc = 0, mArgv = 0xbfc103c4}, mSignalMutex = {
__data = {__lock = 0, __count = 0, __owner = 0, __kind = 0,
__nusers = 0, {__spins = 0, __list = {__next = 0x0}}},
__size = '\000' <repeats 23 times>, __align = 0}, mCond = {
__data = {__lock = 0, __futex = 110, __total_seq = 55,
__wakeup_seq = 55, __woken_seq = 55, __mutex = 0xbfc1025c,
__nwaiters = 0, __broadcast_seq = 0},
__size = "\000\000\000\000n\000\000\000\067\000\000\000\000\000\000\000\067\000\000\000\000\000\000\000\067\000\000\000\000\000\000\000\002\301\277\000\000\000\000\000\000\000\000\000x\032\b", __align = 472446402560},
mSignals = 3, mUseReadline = false, mInputShouldBeRunning = true,
mInputBuf = {mCapacity = 1280,
mPtr = 0x86ae1fc "ose;\flPort.new( "/dev/ttyUSB0", 9600 )\ft', [ 2 ], false)\033ispPerformCommand('documentSetProperty', [ 5, 'prSetTitle', "SCLang:PostBuffer" ], false)\033Emacs.lispPerformCommand('documentSetProperty', [ 5"...,
mData = 0x86ae1f8 "a\fa\fose;\flPort.new( "/dev/ttyUSB0", 9600 )\ft', [ 2 ], false)\033ispPerformCommand('documentSetProperty', [ 5, 'prSetTitle', "SCLang:PostBuffer" ], false)\033Emacs.lispPerformCommand('documentSetProperty',"...}, mInputCtlPipe = {7, 8}, mInputThread = 2987314032, mInputMutex = {
__data = {__lock = 0, __count = 0, __owner = 0, __kind = 0,
__nusers = 0, {__spins = 0, __list = {__next = 0x0}}},
__size = '\000' <repeats 23 times>, __align = 0}, mInputCond = {
__data = {__lock = 0, __futex = 0, __total_seq = 0,
__wakeup_seq = 0, __woken_seq = 0, __mutex = 0x0,
__nwaiters = 0, __broadcast_seq = 0},
__size = '\000' <repeats 44 times>"\251, {\034\b", __align = 0}}

@sensestage
Copy link
Contributor

(again from the version without Qt and scide built).

(gdb) thread apply all bt full

Thread 8 (Thread 0xb7500b70 (LWP 4256)):
#0  0x00507416 in __kernel_vsyscall ()
No symbol table info available.
#1  0x0018ee38 in recvfrom () from /lib/i386-linux-gnu/libpthread.so.0
No symbol table info available.
#2  0x0816cf50 in recvfrom (__addr_len=<optimized out>, __addr=0x864e9dc, 
    __flags=0, __n=65536, __buf=0x866eea8, __fd=<optimized out>)
    at /usr/include/i386-linux-gnu/bits/socket2.h:77
No locals.
#3  SC_UdpInPort::Run (this=0x866ee88)
    at /home/nescivi/git/supercollidergit/supercollider/lang/LangPrimSource/SC_ComPort.cpp:367
        size = <optimized out>
        packet = 0x864e9d0
#4  0x00187d31 in start_thread () from /lib/i386-linux-gnu/libpthread.so.0
No symbol table info available.
#5  0x006fb46e in clone () from /lib/i386-linux-gnu/libc.so.6
No symbol table info available.
Backtrace stopped: Not enough registers or memory available to unwind further

Thread 7 (Thread 0xb60f5b70 (LWP 4258)):
#0  0x00507416 in __kernel_vsyscall ()
---Type <return> to continue, or q <return> to quit---
No symbol table info available.
#1  0x0018ba5c in pthread_cond_wait@@GLIBC_2.3.2 ()
   from /lib/i386-linux-gnu/libpthread.so.0
No symbol table info available.
#2  0x080c0d77 in TempoClock::Run (this=0x864e3d0)
    at /home/nescivi/git/supercollidergit/supercollider/lang/LangPrimSource/PyrSched.cpp:877
        elapsedBeats = <optimized out>
        __PRETTY_FUNCTION__ = "void* TempoClock::Run()"
#3  0x00187d31 in start_thread () from /lib/i386-linux-gnu/libpthread.so.0
No symbol table info available.
#4  0x006fb46e in clone () from /lib/i386-linux-gnu/libc.so.6
No symbol table info available.
Backtrace stopped: Not enough registers or memory available to unwind further

Thread 6 (Thread 0xb48f1b70 (LWP 4264)):
#0  0x00507416 in __kernel_vsyscall ()
No symbol table info available.
#1  0x0018ba5c in pthread_cond_wait@@GLIBC_2.3.2 ()
   from /lib/i386-linux-gnu/libpthread.so.0
No symbol table info available.
#2  0x080c0d77 in TempoClock::Run (this=0x86adc38)
    at /home/nescivi/git/supercollidergit/supercollider/lang/LangPrimSource/PyrS---Type <return> to continue, or q <return> to quit---
ched.cpp:877
        elapsedBeats = <optimized out>
        __PRETTY_FUNCTION__ = "void* TempoClock::Run()"
#3  0x00187d31 in start_thread () from /lib/i386-linux-gnu/libpthread.so.0
No symbol table info available.
#4  0x006fb46e in clone () from /lib/i386-linux-gnu/libc.so.6
No symbol table info available.
Backtrace stopped: Not enough registers or memory available to unwind further

Thread 5 (Thread 0xb40f0b70 (LWP 4265)):
#0  0x00507416 in __kernel_vsyscall ()
No symbol table info available.
#1  0x0018ba5c in pthread_cond_wait@@GLIBC_2.3.2 ()
   from /lib/i386-linux-gnu/libpthread.so.0
No symbol table info available.
#2  0x080c0d77 in TempoClock::Run (this=0x86add48)
    at /home/nescivi/git/supercollidergit/supercollider/lang/LangPrimSource/PyrSched.cpp:877
        elapsedBeats = <optimized out>
        __PRETTY_FUNCTION__ = "void* TempoClock::Run()"
#3  0x00187d31 in start_thread () from /lib/i386-linux-gnu/libpthread.so.0
No symbol table info available.
#4  0x006fb46e in clone () from /lib/i386-linux-gnu/libc.so.6
---Type <return> to continue, or q <return> to quit---
No symbol table info available.
Backtrace stopped: Not enough registers or memory available to unwind further

Thread 4 (Thread 0xb38efb70 (LWP 4267)):
#0  0x00507416 in __kernel_vsyscall ()
No symbol table info available.
#1  0x006f4271 in select () from /lib/i386-linux-gnu/libc.so.6
No symbol table info available.
#2  0x08163f4b in SC_LIDManager::loop (this=0x8254920)
    at /home/nescivi/git/supercollidergit/supercollider/lang/LangPrimSource/SC_LID.cpp:481
        fds = {fds_bits = {16, 0 <repeats 31 times>}}
        n = <optimized out>
#3  0x0816413f in SC_LIDManager::threadFunc (arg=0x8254920)
    at /home/nescivi/git/supercollidergit/supercollider/lang/LangPrimSource/SC_LID.cpp:469
No locals.
#4  0x00187d31 in start_thread () from /lib/i386-linux-gnu/libpthread.so.0
No symbol table info available.
#5  0x006fb46e in clone () from /lib/i386-linux-gnu/libc.so.6
No symbol table info available.
Backtrace stopped: Not enough registers or memory available to unwind further

---Type <return> to continue, or q <return> to quit---
Thread 3 (Thread 0xb28edb70 (LWP 4271)):
#0  0x00507416 in __kernel_vsyscall ()
No symbol table info available.
#1  0x0018ba5c in pthread_cond_wait@@GLIBC_2.3.2 ()
   from /lib/i386-linux-gnu/libpthread.so.0
No symbol table info available.
#2  0x080bfbf0 in schedRunFunc (arg=0x0)
    at /home/nescivi/git/supercollidergit/supercollider/lang/LangPrimSource/PyrSched.cpp:443
        elapsed = -nan(0x8000000000000)
        g = 0x824f080
        inQueue = 0x8858d60
        __PRETTY_FUNCTION__ = "void* schedRunFunc(void*)"
#3  0x00187d31 in start_thread () from /lib/i386-linux-gnu/libpthread.so.0
No symbol table info available.
#4  0x006fb46e in clone () from /lib/i386-linux-gnu/libc.so.6
No symbol table info available.
Backtrace stopped: Not enough registers or memory available to unwind further

Thread 2 (Thread 0xb20ecb70 (LWP 4272)):
#0  0x00507416 in __kernel_vsyscall ()
No symbol table info available.
#1  0x006f4271 in select () from /lib/i386-linux-gnu/libc.so.6
---Type <return> to continue, or q <return> to quit---
No symbol table info available.
#2  0x080bd835 in SC_TerminalClient::pipeFunc (arg=0xbfc1021c)
    at /home/nescivi/git/supercollidergit/supercollider/lang/LangSource/SC_TerminalClient.cpp:653
        bytes = <optimized out>
        buf = "a\fclose;\flPort.new( \"/dev/ttyUSB0\", 9600 )\ft', [ 2 ], false)\033HandleCommandResult(0, 'wid-edit')\033mmand('documentSetProperty', [ 2, 'prSetEdited', true ], false)\033Emacs.lispPerformCommand('documentSetCurr"...
        fds = {fds_bits = {129, 0 <repeats 31 times>}}
        client = 0xbfc1021c
        stack = {mCapacity = 256, 
          mPtr = 0x86ae0f0 "a.close;alPort.new( \"/dev/ttyUSB0\", 9600 )nt', [ 2 ], false)l-table.2124KPp\" ], true)*\" ], false))nescivi/.local/share/SuperCollider/GeneralHIDSpecs", 
          mData = 0x86ae0f0 "a.close;alPort.new( \"/dev/ttyUSB0\", 9600 )nt', [ 2 ], false)l-table.2124KPp\" ], true)*\" ], false))nescivi/.local/share/SuperCollider/GeneralHIDSpecs"}
#3  0x00187d31 in start_thread () from /lib/i386-linux-gnu/libpthread.so.0
No symbol table info available.
#4  0x006fb46e in clone () from /lib/i386-linux-gnu/libc.so.6
No symbol table info available.
Backtrace stopped: Not enough registers or memory available to unwind further

---Type <return> to continue, or q <return> to quit---
Thread 1 (Thread 0xb77036d0 (LWP 4255)):
#0  0x00507416 in __kernel_vsyscall ()
No symbol table info available.
#1  0x0018e619 in __lll_lock_wait () from /lib/i386-linux-gnu/libpthread.so.0
No symbol table info available.
#2  0x00189f7d in _L_lock_708 () from /lib/i386-linux-gnu/libpthread.so.0
No symbol table info available.
#3  0x00189dc3 in pthread_mutex_lock ()
   from /lib/i386-linux-gnu/libpthread.so.0
No symbol table info available.
#4  0x080bd3d2 in lock (this=<optimized out>)
    at /home/nescivi/git/supercollidergit/supercollider/include/lang/SC_LanguageClient.h:148
No locals.
#5  SC_TerminalClient::commandLoop (this=0xbfc1021c)
    at /home/nescivi/git/supercollidergit/supercollider/lang/LangSource/SC_TerminalClient.cpp:413
        secs = 1348233441.3246291
        sig = 2
        haveNext = true
        nextAbsTime = {tv_sec = 1348233441, tv_nsec = 324629068}
#6  0x080bdd56 in SC_TerminalClient::run (this=0xbfc1021c, argc=0, 
    argv=0xbfc103c4)
---Type <return> to continue, or q <return> to quit---
    at /home/nescivi/git/supercollidergit/supercollider/lang/LangSource/SC_TerminalClient.cpp:276
        opt = @0xbfc1023c
        codeFile = 0x0
#7  0x080ac297 in main (argc=4, argv=0xbfc103b4)
    at /home/nescivi/git/supercollidergit/supercollider/lang/LangSource/cmdLineFuncs.cpp:43
        app = {<SC_LanguageClient> = {_vptr.SC_LanguageClient = 0x81c8348, 
            static s_interpretCmdLine = 0xb76cfb70, 
            static s_interpretPrintCmdLine = 0xb76cfb90, 
            static s_run = 0xb76c9870, static s_stop = 0xb76cfbb0, 
            mName = 0x865ec30 "sclang", mPostFile = 0x0, mScratch = {
              mCapacity = 256, mPtr = 0x86a1180 "85z", 
              mData = 0x86a1180 "85z"}, mRunning = true, 
            static gInstance = 0xbfc1021c, static gInstanceMutex = {mutex = {
                __data = {__lock = 0, __count = 0, __owner = 0, __kind = 0, 
                  __nusers = 0, {__spins = 0, __list = {__next = 0x0}}}, 
                __size = '\000' <repeats 23 times>, __align = 0}}}, 
          mShouldBeRunning = true, mReturnCode = 0, 
          mOptions = {<SC_LanguageClient::Options> = {mMemSpace = 2097152, 
              mMemGrow = 262144, mPort = 57120, 
              mRuntimeDir = 0xbfc10b8d "/home/nescivi/SuperCollider/"}, 
            mLibraryConfigFile = 0x0, mDaemon = false, mCallRun = false, 
---Type <return> to continue, or q <return> to quit---
            mCallStop = false, mArgc = 0, mArgv = 0xbfc103c4}, mSignalMutex = {
            __data = {__lock = 0, __count = 0, __owner = 0, __kind = 0, 
              __nusers = 0, {__spins = 0, __list = {__next = 0x0}}}, 
            __size = '\000' <repeats 23 times>, __align = 0}, mCond = {
            __data = {__lock = 0, __futex = 110, __total_seq = 55, 
              __wakeup_seq = 55, __woken_seq = 55, __mutex = 0xbfc1025c, 
              __nwaiters = 0, __broadcast_seq = 0}, 
            __size = "\000\000\000\000n\000\000\000\067\000\000\000\000\000\000\000\067\000\000\000\000\000\000\000\067\000\000\000\000\000\000\000\\\002\301\277\000\000\000\000\000\000\000\000\000x\032\b", __align = 472446402560}, 
          mSignals = 3, mUseReadline = false, mInputShouldBeRunning = true, 
          mInputBuf = {mCapacity = 1280, 
            mPtr = 0x86ae1fc "ose;\flPort.new( \"/dev/ttyUSB0\", 9600 )\ft', [ 2 ], false)\033ispPerformCommand('documentSetProperty', [ 5, 'prSetTitle', \"*SCLang:PostBuffer*\" ], false)\033Emacs.lispPerformCommand('documentSetProperty', [ 5"..., 
            mData = 0x86ae1f8 "a\fa\fose;\flPort.new( \"/dev/ttyUSB0\", 9600 )\ft', [ 2 ], false)\033ispPerformCommand('documentSetProperty', [ 5, 'prSetTitle', \"*SCLang:PostBuffer*\" ], false)\033Emacs.lispPerformCommand('documentSetProperty',"...}, mInputCtlPipe = {7, 8}, mInputThread = 2987314032, mInputMutex = {
            __data = {__lock = 0, __count = 0, __owner = 0, __kind = 0, 
              __nusers = 0, {__spins = 0, __list = {__next = 0x0}}}, 
            __size = '\000' <repeats 23 times>, __align = 0}, mInputCond = {
---Type <return> to continue, or q <return> to quit---
            __data = {__lock = 0, __futex = 0, __total_seq = 0, 
              __wakeup_seq = 0, __woken_seq = 0, __mutex = 0x0, 
              __nwaiters = 0, __broadcast_seq = 0}, 
            __size = '\000' <repeats 44 times>"\251, {\034\b", __align = 0}}

@sensestage
Copy link
Contributor

any suggestions how I can set up kdevelop nicely with SC to debug this in a more convenient way than gdb in the terminal?

@timblechmann
Copy link
Contributor

in both kdevelop and qtcreator you can simply open the root CMakeLists.txt file and it will populate a project for you

@sensestage
Copy link
Contributor

strangely enough, I don't see the thread in here that is actually dealing with the serial port.

The SerialPort::doneAction() function gets called at the end of the SerialPort::threadLoop() function, i.e. when the thread is getting to an end...

@timblechmann
Copy link
Contributor

seeing this as well ... is it possible that the doneAction is called, and the deadlock happens after? looks more like it does not properly unlock the language mutex

@sensestage
Copy link
Contributor

I had some debugging prints added in the doneAction function:

postfl( "doneAction m_running (%d), m_dodone (%d)\n", (int) m_running,
(int) m_dodone );

int status = lockLanguageOrQuit(m_dodone);
if (status == EINTR)
    postfl("EINTR when locking language (%d)\n", status);
    return;
if (status) {
    postfl("error when locking language (%d)\n", status);
    return;
}
postfl("success locking language (%d)\n", status);

and only the first print is printed, none of the others are. But getting
kdevelop up and running now, so I can add some breakpoints and stuff.

sincerely,
Marije

On Fri, Sep 21, 2012 at 3:32 PM, Tim Blechmann notifications@github.comwrote:

seeing this as well ... is it possible that the doneAction is called, and
the deadlock happens after? looks more like it does not properly unlock the
language mutex


Reply to this email directly or view it on GitHubhttps://github.com//issues/434#issuecomment-8764705.

@sensestage
Copy link
Contributor

hmm.. seems that during debugging I caused the lockup...
forgot to add curly brackets after the if statement after adding the print
there...

(that's why I always write the curly brackets, no matter what).

sincerely,
Marije

On Fri, Sep 21, 2012 at 3:38 PM, nescivi nescivi@gmail.com wrote:

I had some debugging prints added in the doneAction function:

postfl( "doneAction m_running (%d), m_dodone (%d)\n", (int) m_running,
(int) m_dodone );

int status = lockLanguageOrQuit(m_dodone);
if (status == EINTR)
    postfl("EINTR when locking language (%d)\n", status);
    return;
if (status) {
    postfl("error when locking language (%d)\n", status);
    return;
}
postfl("success locking language (%d)\n", status);

and only the first print is printed, none of the others are. But getting
kdevelop up and running now, so I can add some breakpoints and stuff.

sincerely,
Marije

On Fri, Sep 21, 2012 at 3:32 PM, Tim Blechmann notifications@github.comwrote:

seeing this as well ... is it possible that the doneAction is called, and
the deadlock happens after? looks more like it does not properly unlock the
language mutex


Reply to this email directly or view it on GitHubhttps://github.com//issues/434#issuecomment-8764705.

@sensestage
Copy link
Contributor

Hiho,

ok,
here are some patches (feel free to squash them to hide my intermediate
stages; I couldn't find a reference on how that worked quickly).
And just make sure you revert the fix you made earlier too.

sincerely,
Marije

On Fri, Sep 21, 2012 at 4:37 PM, nescivi nescivi@gmail.com wrote:

hmm.. seems that during debugging I caused the lockup...
forgot to add curly brackets after the if statement after adding the print
there...

(that's why I always write the curly brackets, no matter what).

sincerely,
Marije

On Fri, Sep 21, 2012 at 3:38 PM, nescivi nescivi@gmail.com wrote:

I had some debugging prints added in the doneAction function:

postfl( "doneAction m_running (%d), m_dodone (%d)\n", (int) m_running,
(int) m_dodone );

int status = lockLanguageOrQuit(m_dodone);
if (status == EINTR)
    postfl("EINTR when locking language (%d)\n", status);
    return;
if (status) {
    postfl("error when locking language (%d)\n", status);
    return;
}
postfl("success locking language (%d)\n", status);

and only the first print is printed, none of the others are. But getting
kdevelop up and running now, so I can add some breakpoints and stuff.

sincerely,
Marije

On Fri, Sep 21, 2012 at 3:32 PM, Tim Blechmann notifications@github.comwrote:

seeing this as well ... is it possible that the doneAction is called,
and the deadlock happens after? looks more like it does not properly unlock
the language mutex


Reply to this email directly or view it on GitHubhttps://github.com//issues/434#issuecomment-8764705.

@timblechmann
Copy link
Contributor

github seems to filter attachments. would it be possible that you send me the patches via mail?

@timblechmann
Copy link
Contributor

pushed only the fix and did some cleanups in the class library file

@sensestage
Copy link
Contributor

Hiho,

should this also be backported to 3.5?

sincerely,
Marije

On Friday 21 September 2012 18:43:42 Tim Blechmann wrote:

pushed only the fix and did some cleanups in the class library file


Reply to this email directly or view it on GitHub:
#434 (comment)
469

@timblechmann
Copy link
Contributor

done

@redFrik
Copy link
Contributor Author

redFrik commented Sep 22, 2012

many thanks for fixing this.
i'll test it later today.
_f

22 sep 2012 kl. 12:31 skrev Tim Blechmann notifications@github.com:

done


Reply to this email directly or view it on GitHub.

#|
fredrikolofsson.com musicalfieldsforever.com
|#

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues that relate to unexpected/unwanted behavior. Don't use for PRs. comp: sclang sclang C++ implementation (primitives, etc.). for changes to class lib use "comp: class library"
Projects
None yet
Development

No branches or pull requests

4 participants