9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] malloc/ (long)((void*)v)
@ 2006-01-31 17:42 Noah Evans
  2006-01-31 19:24 ` Charles Forsyth
  2006-01-31 19:33 ` Ronald G Minnich
  0 siblings, 2 replies; 5+ messages in thread
From: Noah Evans @ 2006-01-31 17:42 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs Bell Labs

One last question before I go to bed.

I've got the Data and BSS sections set up reasonably it seems, but  
malloc blows the kernel to shreds. I think I've traced the problem  
down to PADDR which tries to get a variable's physical address by  
coercing it to a void pointer and then back to a long. xalloc seems  
to be looking for the physical address of the memory segment it's  
being sent but it getting null instead. This is actually quite  
amusing because xalloc ends up tromping through graphics memory. Also  
this only happens to variables that are in the data or bss sections.  
PADDR returns the address of 'end' just fine.

What should I do to fix this?

Noah




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [9fans] malloc/ (long)((void*)v)
  2006-01-31 17:42 [9fans] malloc/ (long)((void*)v) Noah Evans
@ 2006-01-31 19:24 ` Charles Forsyth
  2006-01-31 19:33 ` Ronald G Minnich
  1 sibling, 0 replies; 5+ messages in thread
From: Charles Forsyth @ 2006-01-31 19:24 UTC (permalink / raw)
  To: 9fans

>>What should I do to fix this?

there are a few things that need to be set up consistently.
i'll switch to private e-mail for that.


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [9fans] malloc/ (long)((void*)v)
  2006-01-31 17:42 [9fans] malloc/ (long)((void*)v) Noah Evans
  2006-01-31 19:24 ` Charles Forsyth
@ 2006-01-31 19:33 ` Ronald G Minnich
  2006-01-31 19:42   ` Charles Forsyth
  2006-02-01  2:02   ` Noah Evans
  1 sibling, 2 replies; 5+ messages in thread
From: Ronald G Minnich @ 2006-01-31 19:33 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Noah Evans wrote:
> One last question before I go to bed.
> 
> I've got the Data and BSS sections set up reasonably it seems, but  
> malloc blows the kernel to shreds.

it might be what you said, but when I've had this before it's because I 
screwed up the location of the data segment, in which case initialized 
data was wrong.

So, for test, I did this:

int something = 0x55aaaa55;

main(){
.
.
.
	if (something != 0x55aaaa55)
		die()




ron


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [9fans] malloc/ (long)((void*)v)
  2006-01-31 19:33 ` Ronald G Minnich
@ 2006-01-31 19:42   ` Charles Forsyth
  2006-02-01  2:02   ` Noah Evans
  1 sibling, 0 replies; 5+ messages in thread
From: Charles Forsyth @ 2006-01-31 19:42 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 227 bytes --]

yes, and don't forget that
	print("hello world\n");
might not be a good equivalent test if strings are in the text segment.
(it's amazing how far the code can get into and sometimes out of things like print
with data wrong)

[-- Attachment #2: Type: message/rfc822, Size: 3213 bytes --]

From: Ronald G Minnich <rminnich@lanl.gov>
To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu>
Subject: Re: [9fans] malloc/ (long)((void*)v)
Date: Tue, 31 Jan 2006 12:33:12 -0700
Message-ID: <43DFBB78.4030006@lanl.gov>

Noah Evans wrote:
> One last question before I go to bed.
> 
> I've got the Data and BSS sections set up reasonably it seems, but  
> malloc blows the kernel to shreds.

it might be what you said, but when I've had this before it's because I 
screwed up the location of the data segment, in which case initialized 
data was wrong.

So, for test, I did this:

int something = 0x55aaaa55;

main(){
.
.
.
	if (something != 0x55aaaa55)
		die()




ron

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [9fans] malloc/ (long)((void*)v)
  2006-01-31 19:33 ` Ronald G Minnich
  2006-01-31 19:42   ` Charles Forsyth
@ 2006-02-01  2:02   ` Noah Evans
  1 sibling, 0 replies; 5+ messages in thread
From: Noah Evans @ 2006-02-01  2:02 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Bingo:

ulong test = 0xAFAFAFAF;

void
main(void)
{

	ulong i = 0, j = 0;
	memcpy(etext,bdata,edata-bdata);
	memset(edata, 0, end-edata);		/* clear the BSS */
	
	while(1) {
		i++; /* change a lot so I can see which reg its in */

Watching the registers(no screen yet) the value is getting hosed.

Noah

On Feb 1, 2006, at 4:33 AM, Ronald G Minnich wrote:

> Noah Evans wrote:
>> One last question before I go to bed.
>> I've got the Data and BSS sections set up reasonably it seems,  
>> but  malloc blows the kernel to shreds.
>
> it might be what you said, but when I've had this before it's  
> because I screwed up the location of the data segment, in which  
> case initialized data was wrong.
>
> So, for test, I did this:
>
> int something = 0x55aaaa55;
>
> main(){
> .
> .
> .
> 	if (something != 0x55aaaa55)
> 		die()
>
>
>
>
> ron



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-02-01  2:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-31 17:42 [9fans] malloc/ (long)((void*)v) Noah Evans
2006-01-31 19:24 ` Charles Forsyth
2006-01-31 19:33 ` Ronald G Minnich
2006-01-31 19:42   ` Charles Forsyth
2006-02-01  2:02   ` Noah Evans

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).