473,386 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

corrupted pointer when initing a dll

jc
i'm developing a project using vc++.
the main exe is a win32 application. it needs two dlls. one is my own
implementation of string operations. the other dll is to parse a2l
files(it is similar to xml files, but it is based on asap2 standard).
i created the parser using bison and flex. then ported the code to vc+
+ environment including the files lex.yy.c(output from the flex
scanner) a2lgrammar.tab.cpp(output from bison) for post processing the
parser output and creating the data structure. the result is a dll
file that i link with my application.

all was well till i realized that this post processing the parser
output(while the parser can finish parsing the file in less than a
minute for a typical a2l file will be around 150,000 lines) takes
around 10 minutes, during the entire application freezes. so i decided
to call the parsing using a separate thread.

i call the parser with the file name. before i call the parser
function i initialize the parser manually.

i reach the parser application in two different paths. in one path
there is a conf file, which has the info about the a2l file and from
there it calls the parser application. this goes well with no problem.

but if i try to load the a2l file directly then the filename pointer
gets corrupted. in different ways
sometimes when i enter the thread
sometimes when i initialize the dll
sometimes when i parse the file

but nothing happens when i call the a2l parse and process thread after
i load the conf file.

i spent a week trying to figure this out and realized that this is
beyond me.
any help and pointer will be appreciated

thanks

jc

Apr 30 '07 #1
7 2515
On 30 Apr, 14:23, jc <k.jayachand...@gmail.comwrote:
i'm developing a project using vc++.
the main exe is a win32 application. it needs two dlls. one is my own
implementation of string operations. the other dll is to parse a2l
files(it is similar to xml files, but it is based on asap2 standard).
i created the parser using bison and flex. then ported the code to vc+
+ environment including the files lex.yy.c(output from the flex
scanner) a2lgrammar.tab.cpp(output from bison) for post processing the
parser output and creating the data structure. the result is a dll
file that i link with my application.

all was well till i realized that this post processing the parser
output(while the parser can finish parsing the file in less than a
minute for a typical a2l file will be around 150,000 lines) takes
around 10 minutes, during the entire application freezes. so i decided
to call the parsing using a separate thread.

i call the parser with the file name. before i call the parser
function i initialize the parser manually.

i reach the parser application in two different paths. in one path
there is a conf file, which has the info about the a2l file and from
there it calls the parser application. this goes well with no problem.

but if i try to load the a2l file directly then the filename pointer
gets corrupted. in different ways
sometimes when i enter the thread
sometimes when i initialize the dll
sometimes when i parse the file

but nothing happens when i call the a2l parse and process thread after
i load the conf file.

i spent a week trying to figure this out and realized that this is
beyond me.
any help and pointer will be appreciated
this is W32 not C++ problem

are you starting that thread inside DLLMain?

check this:
http://boost.org/doc/html/threads/im...on_notes.win32
Apr 30 '07 #2
jc
On Apr 30, 9:32 am, dasjotre <dasjo...@googlemail.comwrote:
On 30 Apr, 14:23, jc <k.jayachand...@gmail.comwrote:


i'm developing a project using vc++.
the main exe is a win32 application. it needs two dlls. one is my own
implementation of string operations. the other dll is to parse a2l
files(it is similar to xml files, but it is based on asap2 standard).
i created the parser using bison and flex. then ported the code to vc+
+ environment including the files lex.yy.c(output from the flex
scanner) a2lgrammar.tab.cpp(output from bison) for post processing the
parser output and creating the data structure. the result is a dll
file that i link with my application.
all was well till i realized that this post processing the parser
output(while the parser can finish parsing the file in less than a
minute for a typical a2l file will be around 150,000 lines) takes
around 10 minutes, during the entire application freezes. so i decided
to call the parsing using a separate thread.
i call the parser with the file name. before i call the parser
function i initialize the parser manually.
i reach the parser application in two different paths. in one path
there is a conf file, which has the info about the a2l file and from
there it calls the parser application. this goes well with no problem.
but if i try to load the a2l file directly then the filename pointer
gets corrupted. in different ways
sometimes when i enter the thread
sometimes when i initialize the dll
sometimes when i parse the file
but nothing happens when i call the a2l parse and process thread after
i load the conf file.
i spent a week trying to figure this out and realized that this is
beyond me.
any help and pointer will be appreciated

this is W32 not C++ problem

are you starting that thread inside DLLMain?

check this:http://boost.org/doc/html/threads/im...#threads.i...- Hide quoted text -

- Show quoted text -
no i start the thread inside my application and call the dll functions
from the thread.
i don't think i have anything like dllMain.
there are three functions that i use
0. start the thread (sometimes this file name pointer corrupts here)
1. initparser (this initialises the classes that parse, this is very
useful for me because, this will let me reparse a different file
without closing the application)(it corrupts here too)
2. parser(file name)(if it escaped before, now it is sure that it gets
corrupted)
3. postprocess
4. copythe datastructure from the dll to the application(here i
duplicate all the strucutre, as it will be deleted soon, but these
data structure i need for the application)
4. deleteparser(delete all the memory that i allocated)

thanks
jc

Apr 30 '07 #3

"jc" <k.************@gmail.comwrote in message
news:11********************@y5g2000hsa.googlegroup s.com...
i'm developing a project using vc++.
the main exe is a win32 application. it needs two dlls.
These are not related to the C++ language. You need to ask in a microsoft
newsgroup.

-Howard
Apr 30 '07 #4
Howard wrote, On 30/04/07 18:06:
"jc" <k.************@gmail.comwrote in message
news:11********************@y5g2000hsa.googlegroup s.com...
>i'm developing a project using vc++.
the main exe is a win32 application. it needs two dlls.

These are not related to the C++ language. You need to ask in a microsoft
newsgroup.
The OP did, it was cross-posted there. It was also cross-posted to
comp.lang.c which shows a certain level of *lack* of knowledge, since as
I'm sure *you* know C is a different language.

Even if the OP is using C you are correct that this is MS specific, so
would people please direct the MS specific answers to the MS group only.
Thanks.

FU set.
--
Flash Gordon
Apr 30 '07 #5
Make sure you are not passing pointers on your stack for your
thread to use. Always allocate on the heap data you are to send
to a different thread. Note this is just an educated guess as it's
hard to tell what your problem is with no code posted...

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: ag********@mvps.org
MVP VC FAQ: http://vcfaq.mvps.org
=====================================

"jc" <k.************@gmail.comwrote in message
news:11**********************@n76g2000hsh.googlegr oups.com...
On Apr 30, 9:32 am, dasjotre <dasjo...@googlemail.comwrote:
>On 30 Apr, 14:23, jc <k.jayachand...@gmail.comwrote:


i'm developing a project using vc++.
the main exe is a win32 application. it needs two dlls. one is my own
implementation of string operations. the other dll is to parse a2l
files(it is similar to xml files, but it is based on asap2 standard).
i created the parser using bison and flex. then ported the code to vc+
+ environment including the files lex.yy.c(output from the flex
scanner) a2lgrammar.tab.cpp(output from bison) for post processing the
parser output and creating the data structure. the result is a dll
file that i link with my application.
all was well till i realized that this post processing the parser
output(while the parser can finish parsing the file in less than a
minute for a typical a2l file will be around 150,000 lines) takes
around 10 minutes, during the entire application freezes. so i decided
to call the parsing using a separate thread.
i call the parser with the file name. before i call the parser
function i initialize the parser manually.
i reach the parser application in two different paths. in one path
there is a conf file, which has the info about the a2l file and from
there it calls the parser application. this goes well with no problem.
but if i try to load the a2l file directly then the filename pointer
gets corrupted. in different ways
sometimes when i enter the thread
sometimes when i initialize the dll
sometimes when i parse the file
but nothing happens when i call the a2l parse and process thread after
i load the conf file.
i spent a week trying to figure this out and realized that this is
beyond me.
any help and pointer will be appreciated

this is W32 not C++ problem

are you starting that thread inside DLLMain?

check
this:http://boost.org/doc/html/threads/im...#threads.i...-
Hide quoted text -

- Show quoted text -

no i start the thread inside my application and call the dll functions
from the thread.
i don't think i have anything like dllMain.
there are three functions that i use
0. start the thread (sometimes this file name pointer corrupts here)
1. initparser (this initialises the classes that parse, this is very
useful for me because, this will let me reparse a different file
without closing the application)(it corrupts here too)
2. parser(file name)(if it escaped before, now it is sure that it gets
corrupted)
3. postprocess
4. copythe datastructure from the dll to the application(here i
duplicate all the strucutre, as it will be deleted soon, but these
data structure i need for the application)
4. deleteparser(delete all the memory that i allocated)

thanks
jc

Apr 30 '07 #6
jc
the corresponding code is

int CCCP::StartLoadA2lThread(void){
/*
function ccp thread
parameters: void
*/
//CParseWaitDialog *p_pwd;
DWORD dParseThreadID;
m_pWD = DisplayParseWaitDialog();
m_bA2lLoadThreadActive = TRUE;
if(m_hA2lLoadThread){
CloseHandle(m_hA2lLoadThread);
}
m_hA2lLoadThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)
ParseA2lThread, this, 0,&dParseThreadID);
if(m_hA2lLoadThread){
sGmsg.StringCopy("parsing a2l file thread started");
m_pParent->SendMessage(CM_PRINT_MESSAGE2);
}
else{
sGmsg.StringCopy("a2l parse thread not started");
m_pParent->SendMessage(CM_PRINT_MESSAGE2);
}
return 1;

}
void CCCP::ParseA2lThread(LPVOID p){
/*
*/
CCCP *w = (CCCP *)p;
w->LoadA2LDatabase(w->m_strA2Lfname);
_endthread();
}
int CCCP::LoadA2LDatabase(jcStr *fname){
/*
then call parser to parse the a2l file and load all the channel
values, if the parser returns with no error
return result of the load and parse.
zero is returned if no error in loading and parsing the a2l file
*/
int retval;

InitParser();//this will init the parser objects
char *temp;
//InitParser();
//fname = m_strA2Lfname;
temp = fname->ReturnStr();
retval = Parser(temp, m_bA2lParseTalkative);
AnalyzeParseError(retval, fname, m_pWD);
DeleteParser();
InitTempLog();
m_pParent->PostMessage(CM_A2L_FILE_LOADED);
//AfterILoadA2lFile();
return retval;
}
thanks
jc
On Apr 30, 2:31 pm, "Alexander Nickolov" <agnicko...@mvps.orgwrote:
Make sure you are not passing pointers on your stack for your
thread to use. Always allocate on the heap data you are to send
to a different thread. Note this is just an educated guess as it's
hard to tell what your problem is with no code posted...

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnicko...@mvps.org
MVP VC FAQ:http://vcfaq.mvps.org
=====================================

"jc" <k.jayachand...@gmail.comwrote in message

news:11**********************@n76g2000hsh.googlegr oups.com...
On Apr 30, 9:32 am, dasjotre <dasjo...@googlemail.comwrote:
On 30 Apr, 14:23, jc <k.jayachand...@gmail.comwrote:
i'm developing a project using vc++.
the main exe is a win32 application. it needs two dlls. one is my own
implementation of string operations. the other dll is to parse a2l
files(it is similar to xml files, but it is based on asap2 standard).
i created the parser using bison and flex. then ported the code to vc+
+ environment including the files lex.yy.c(output from the flex
scanner) a2lgrammar.tab.cpp(output from bison) for post processing the
parser output and creating the data structure. the result is a dll
file that i link with my application.
all was well till i realized that this post processing the parser
output(while the parser can finish parsing the file in less than a
minute for a typical a2l file will be around 150,000 lines) takes
around 10 minutes, during the entire application freezes. so i decided
to call the parsing using a separate thread.
i call the parser with the file name. before i call the parser
function i initialize the parser manually.
i reach the parser application in two different paths. in one path
there is a conf file, which has the info about the a2l file and from
there it calls the parser application. this goes well with no problem.
but if i try to load the a2l file directly then the filename pointer
gets corrupted. in different ways
sometimes when i enter the thread
sometimes when i initialize the dll
sometimes when i parse the file
but nothing happens when i call the a2l parse and process thread after
i load the conf file.
i spent a week trying to figure this out and realized that this is
beyond me.
any help and pointer will be appreciated
this is W32 not C++ problem
are you starting that thread inside DLLMain?
check
this:http://boost.org/doc/html/threads/im...html#threads.i...
Hide quoted text -
- Show quoted text -
no i start the thread inside my application and call the dll functions
from the thread.
i don't think i have anything like dllMain.
there are three functions that i use
0. start the thread (sometimes this file name pointer corrupts here)
1. initparser (this initialises the classes that parse, this is very
useful for me because, this will let me reparse a different file
without closing the application)(it corrupts here too)
2. parser(file name)(if it escaped before, now it is sure that it gets
corrupted)
3. postprocess
4. copythe datastructure from the dll to the application(here i
duplicate all the strucutre, as it will be deleted soon, but these
data structure i need for the application)
4. deleteparser(delete all the memory that i allocated)
thanks
jc

Apr 30 '07 #7
On 30 Apr 2007 13:42:22 -0700, in comp.lang.c , jc
<k.************@gmail.comwrote:
>the corresponding code is

int CCCP::StartLoadA2lThread(void){
This is C++ and Windows code, and horribly offtopic in CLC.
f'ups set.
--
Mark McIntyre

"Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are,
by definition, not smart enough to debug it."
--Brian Kernighan
Apr 30 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Bob Hynes | last post by:
Hi All, Does anyone know of a place where a corrupted mdb(front-end) can be sent and have that place be able to tell me what got corrupted within the db? Here's the issue; All pc's are WindowsNT...
28
by: Lee Rouse | last post by:
Hello all, This is going to be a rather lengthy "question". I have an Access 2k database, separated front end/back end. Front end copies are on about 30 workstations and used frequently during...
32
by: Clunixchit | last post by:
How can i read lines of a file and place each line read in an array? for exemple; array=line1 array=line2 ...
9
by: advance scout | last post by:
HELP! My database is suddenly corrupted. My computer was acting funny (very sluggish) and was shut down. Access had been already been closed down but computer was acting very slow , so perhaps it...
6
by: oskar | last post by:
Hello everyone. I have a problem with my program... and i kinda dunno what to do.. everything seems to work ok, but i'm getting corrupted double-linked list error =\. *** glibc detected ***...
2
by: zl2k | last post by:
hi, I have one program runs fine on my i386 linux box but get the "glibc detected *** corrupted double-linked list" error on the x86_64 linux box. Please help me to figure out if it is my...
6
by: jc | last post by:
i'm developing a project using vc++. the main exe is a win32 application. it needs two dlls. one is my own implementation of string operations. the other dll is to parse a2l files(it is similar to...
12
by: Julien Lafaye | last post by:
Hello, i callocated a pointer to a user-defined struct. The value of the pointer is something like 0x0000002aaaaa (can't remember actually, I don't have the computer running the code with me)....
2
by: greenknt | last post by:
Hi All, Ok here we go; I have a global.h file with a extern char glb_holder; + global.c with char glb_holder; now I have ; (one.c)
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.