This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 118925 - IDE hangs after manipulations with a stack in multithreaded application
Summary: IDE hangs after manipulations with a stack in multithreaded application
Status: VERIFIED FIXED
Alias: None
Product: cnd
Classification: Unclassified
Component: Debugger (show other bugs)
Version: 6.x
Hardware: All Windows XP
: P1 blocker (vote)
Assignee: _ gordonp
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-10-15 18:29 UTC by Alexander Pepin
Modified: 2009-06-25 10:59 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Patch against release60 version (1.04 KB, patch)
2007-11-07 19:22 UTC, _ gordonp
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Pepin 2007-10-15 18:29:36 UTC
I've split issue #118230 as Gordon asked.
The bug is reproducible in build 20071015. Despite the newly implemented "Information" windows "Pop To Here" still works
for "addressed" stack frames.
Steps to reproduce:
- create a new multithreaded application using the following code:

#include <math.h>
#include <sched.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>

volatile int threadcount = 0;
int numThreads;
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;

unsigned long factorial(unsigned long x) {
    if (x <= 1) {
        return 1;
    } else {
        return x * factorial(x-1);
    }
}


// This is the function that is called whenever a thread is created
void *threadfunc(void *args) {
    int id = (int) ((long) args);
    unsigned long fac = factorial((unsigned long)id);
    pthread_mutex_lock(&mutex);
    printf("Thread %3d computed factorial(%3d) = %15lu.\n", id, id, fac);
    pthread_mutex_unlock(&mutex);
    return NULL;
}

int main(int argc, char **argv) {
    
    numThreads = 12;
    if (argc >= 2) {
        numThreads = atoi(argv[1]);
    }
    
    int myid = numThreads;
    for (numThreads--; numThreads > 0; numThreads--) {
        pthread_t tid;
        pthread_mutex_lock(&mutex);
        pthread_create(&tid, NULL, threadfunc, (void*)numThreads) == 0;
	#ifdef linux
        sched_yield();
	#endif
        pthread_mutex_unlock(&mutex);
        pthread_join(tid, NULL);
        
    }
}

- build the project with -pthreads option for both compiler and linker
- set a breakpoint inside the function "factorial(unsigned long x)"
- run debugger
- when the debugger stops at the breakpoint open "Call Stack" window, it contains number of elements "Address:[@0x<hex
address>]"
- call "Pop To Here" several times on any of numerical (addressed) frames, notice that commands work and Information
windows do not block them
Result: IDE hangs. It does not respond any user action and can be closed only by Task Manager.
Comment 1 _ gordonp 2007-10-15 19:47:55 UTC
Yes, its still doing the commands after the popup. It should't be!
Comment 2 Alexander Pepin 2007-10-16 10:31:57 UTC
The information window says "No frame information available. Ignoring request.". Why then it does not ignore in fact?
Comment 3 _ gordonp 2007-10-18 17:17:18 UTC
Fixed (last Monday)
Comment 4 Alexander Pepin 2007-10-23 15:39:23 UTC
The bug is still reproducible in build 20071023
to simplify the previous scenario after stopping at breakpoint do the following steps:
- open Call Stack window
- scroll the stack list and find "Address:[@0x00000000]" element on the bottom of the stack list (it's unusual to have
such an element in the stack so a user probably will try to investigate it)
- do "Pop To Here" on this element 5 times 
Result: IDE hangs.
Comment 5 _ gordonp 2007-11-06 01:28:15 UTC
Fixed. We ignore pop-to-here if the target frame is invalid. Also, we were poping 1 too
few frames (also fixed).
Comment 6 Alexander Pepin 2007-11-07 17:38:08 UTC
verified in trunk build 20071107
Comment 7 Jesse Grodnik 2007-11-07 19:05:50 UTC
This is a requested NB high resistance fix.
Comment 8 _ gordonp 2007-11-07 19:22:22 UTC
Created attachment 52681 [details]
Patch against release60 version
Comment 9 Thomas Preisler 2007-11-07 19:57:33 UTC
Code changes reviewed by Thomas Preisler (thp).
Comment 10 _ gordonp 2007-11-08 23:39:55 UTC
Change committed into release60 branch.
Comment 11 Alexander Pepin 2007-11-09 17:25:40 UTC
verified in RC1 build (20071109)